Polish profile expression support
Issue: SPR-12458
This commit is contained in:
@@ -32,16 +32,16 @@ import java.util.function.Predicate;
|
||||
public interface Profiles {
|
||||
|
||||
/**
|
||||
* Test if this profile predicate matches against the given active profiles
|
||||
* predicate.
|
||||
* Test if this {@code Profiles} instance <em>matches</em> against the given
|
||||
* active profiles predicate.
|
||||
* @param activeProfiles predicate that tests whether a given profile is
|
||||
* currently active
|
||||
*/
|
||||
boolean matches(Predicate<String> activeProfiles);
|
||||
|
||||
/**
|
||||
* Return a new {@link Profiles} instance that checks for matches against the given
|
||||
* profile strings.
|
||||
* Create a new {@link Profiles} instance that checks for matches against
|
||||
* the given <em>profile strings</em>.
|
||||
*
|
||||
* <p>The returned instance will {@linkplain Profiles#matches(Predicate) match}
|
||||
* if any one of the given profile strings matches.
|
||||
@@ -63,7 +63,7 @@ public interface Profiles {
|
||||
* expression; it must be expressed as {@code "(a & b) | c"} or
|
||||
* {@code "a & (b | c)"}.
|
||||
*
|
||||
* @param profiles the profiles to include
|
||||
* @param profiles the <em>profile strings</em> to include
|
||||
* @return a new {@link Profiles} instance
|
||||
*/
|
||||
static Profiles of(String... profiles) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
class ProfilesParser {
|
||||
|
||||
public static Profiles parse(String... expressions) {
|
||||
static Profiles parse(String... expressions) {
|
||||
Assert.notEmpty(expressions, "Must specify at least one profile");
|
||||
Profiles[] parsed = new Profiles[expressions.length];
|
||||
for (int i = 0; i < expressions.length; i++) {
|
||||
@@ -92,7 +92,7 @@ class ProfilesParser {
|
||||
return elements.get(0);
|
||||
}
|
||||
Profiles[] profiles = elements.toArray(new Profiles[0]);
|
||||
return (operator != Operator.AND ? or(profiles) : and(profiles));
|
||||
return (operator == Operator.AND ? and(profiles) : or(profiles));
|
||||
}
|
||||
|
||||
private static void assertWellFormed(String expression, boolean wellFormed) {
|
||||
@@ -111,7 +111,7 @@ class ProfilesParser {
|
||||
}
|
||||
|
||||
private static Profiles not(Profiles profiles) {
|
||||
return (activeProfiles) -> !profiles.matches(activeProfiles);
|
||||
return (activeProfile) -> !profiles.matches(activeProfile);
|
||||
}
|
||||
|
||||
private static Profiles equals(String profile) {
|
||||
@@ -133,7 +133,7 @@ class ProfilesParser {
|
||||
|
||||
private final Profiles[] parsed;
|
||||
|
||||
public ParsedProfiles(String[] expressions, Profiles[] parsed) {
|
||||
ParsedProfiles(String[] expressions, Profiles[] parsed) {
|
||||
this.expressions = expressions;
|
||||
this.parsed = parsed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user