org.springframework.core.env

Interface Profiles

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.


    @FunctionalInterface
    public interface Profiles
    Profile predicate that may be accepted by an Environment.

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

    Since:
    5.1
    Author:
    Phillip Webb
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method and Description
      boolean matches(java.util.function.Predicate<java.lang.String> activeProfiles)
      Test if this Profiles instance matches against the given active profiles predicate.
      static Profiles of(java.lang.String... profiles)
      Create a new Profiles instance that checks for matches against the given profile strings.
    • Method Detail

      • matches

        boolean matches(java.util.function.Predicate<java.lang.String> activeProfiles)
        Test if this Profiles instance matches against the given active profiles predicate.
        Parameters:
        activeProfiles - predicate that tests whether a given profile is currently active
      • of

        static Profiles of(java.lang.String... profiles)
        Create a new Profiles instance that checks for matches against the given profile strings.

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

        A profile string may contain a simple profile name (for example "production") or a profile expression. A profile 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
        • & - A logical and of the profiles
        • | - A logical or of the profiles

        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)".

        Parameters:
        profiles - the profile strings to include
        Returns:
        a new Profiles instance