From ea4c64ebc4d9ac59adfeb983d4b197c6d2c8c0d0 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 25 Apr 2023 15:08:03 +0200 Subject: [PATCH] Polish ProfilesParser internals --- .../springframework/core/env/ProfilesParser.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java index b4a0a0138bb..4fac607d8ff 100644 --- a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java @@ -71,8 +71,8 @@ final class ProfilesParser { } switch (token) { case "(" -> { - Profiles contents = parseTokens(expression, tokens, Context.BRACKET); - if (context == Context.INVERT) { + Profiles contents = parseTokens(expression, tokens, Context.PARENTHESIS); + if (context == Context.NEGATE) { return contents; } elements.add(contents); @@ -85,10 +85,10 @@ final class ProfilesParser { assertWellFormed(expression, operator == null || operator == Operator.OR); operator = Operator.OR; } - case "!" -> elements.add(not(parseTokens(expression, tokens, Context.INVERT))); + case "!" -> elements.add(not(parseTokens(expression, tokens, Context.NEGATE))); case ")" -> { Profiles merged = merge(expression, elements, operator); - if (context == Context.BRACKET) { + if (context == Context.PARENTHESIS) { return merged; } elements.clear(); @@ -97,7 +97,7 @@ final class ProfilesParser { } default -> { Profiles value = equals(token); - if (context == Context.INVERT) { + if (context == Context.NEGATE) { return value; } elements.add(value); @@ -141,10 +141,9 @@ final class ProfilesParser { } - private enum Operator {AND, OR} + private enum Operator { AND, OR } - - private enum Context {NONE, INVERT, BRACKET} + private enum Context { NONE, NEGATE, PARENTHESIS } private static class ParsedProfiles implements Profiles {