Skip to content

Commit 0956c14

Browse files
committed
Polish ProfilesParser internals
1 parent 964950a commit 0956c14

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,8 +71,8 @@ private static Profiles parseTokens(String expression, StringTokenizer tokens, C
7171
}
7272
switch (token) {
7373
case "(":
74-
Profiles contents = parseTokens(expression, tokens, Context.BRACKET);
75-
if (context == Context.INVERT) {
74+
Profiles contents = parseTokens(expression, tokens, Context.PARENTHESIS);
75+
if (context == Context.NEGATE) {
7676
return contents;
7777
}
7878
elements.add(contents);
@@ -86,11 +86,11 @@ private static Profiles parseTokens(String expression, StringTokenizer tokens, C
8686
operator = Operator.OR;
8787
break;
8888
case "!":
89-
elements.add(not(parseTokens(expression, tokens, Context.INVERT)));
89+
elements.add(not(parseTokens(expression, tokens, Context.NEGATE)));
9090
break;
9191
case ")":
9292
Profiles merged = merge(expression, elements, operator);
93-
if (context == Context.BRACKET) {
93+
if (context == Context.PARENTHESIS) {
9494
return merged;
9595
}
9696
elements.clear();
@@ -99,7 +99,7 @@ private static Profiles parseTokens(String expression, StringTokenizer tokens, C
9999
break;
100100
default:
101101
Profiles value = equals(token);
102-
if (context == Context.INVERT) {
102+
if (context == Context.NEGATE) {
103103
return value;
104104
}
105105
elements.add(value);
@@ -142,10 +142,9 @@ private static Predicate<Profiles> isMatch(Predicate<String> activeProfile) {
142142
}
143143

144144

145-
private enum Operator {AND, OR}
145+
private enum Operator { AND, OR }
146146

147-
148-
private enum Context {NONE, INVERT, BRACKET}
147+
private enum Context { NONE, NEGATE, PARENTHESIS }
149148

150149

151150
private static class ParsedProfiles implements Profiles {

0 commit comments

Comments
 (0)