Top Description Methods
org.springframework.core.env

public Interface Profiles

Known Direct Implementers
org.springframework.core.env.ProfilesParser.ParsedProfiles
Annotations
@FunctionalInterface
Imports
java.util.function.Predicate

Profile predicate that may be accepted by an Environment.

May be implemented directly or, more usually, created using the of(...) factory method.

Authors
Phillip Webb, Sam Brannen
Since
5.1
See Also
Environment#acceptsProfiles(Profiles), Environment#matchesProfiles(String...)

Method Summary

Modifier and TypeMethod and Description
public boolean
matches(Predicate<String>
a predicate that tests whether a given profile is currently active
isProfileActive
)

Test if this Profiles instance matches against the given predicate.

public static Profiles

Returns:

a new Profiles instance
of
(String...
the profile expressions to include
profileExpressions
)

Create a new Profiles instance that checks for matches against the given profile expressions.

Method Detail

matchesback to summary
public boolean matches(Predicate<String> isProfileActive)

Test if this Profiles instance matches against the given predicate.

Parameters
isProfileActive:Predicate<String>

a predicate that tests whether a given profile is currently active

ofback to summary
public static Profiles of(String... profileExpressions)

Create a new Profiles instance that checks for matches against the given profile expressions.

The returned instance will match if any one of the given profile expressions matches.

A profile expression may contain a simple profile name (for example "production") or a compound expression. A compound expression allows for more complicated profile logic to be expressed, for example "production & cloud".

The following operators are supported in profile expressions.

  • ! - A logical NOT of the profile name or compound expression
  • & - A logical AND of the profile names or compound expressions
  • | - A logical OR of the profile names or compound expressions

Please note that the & and | operators may not be mixed without using parentheses. For example, "a & b | c" is not a valid expression: it must be expressed as "(a & b) | c" or "a & (b | c)".

As of Spring Framework 5.1.17, two Profiles instances returned by this method are considered equivalent to each other (in terms of equals() and hashCode() semantics) if they are created with identical profile expressions.

Parameters
profileExpressions:String[]

the profile expressions to include

Returns:Profiles

a new Profiles instance