Class Requirement


  • public final class Requirement
    extends Object
    A description of single build agent requirement needed for specific build configurations. A requirement has an associated property name (system property or environment variable), optional value, and type. System property name should be prefixed with Constants.SYSTEM_PREFIX, environment variable name should be prefixed with Constants.ENV_PREFIX There are various Requirement types, such as "exists", "match", "contains" and so on.
    See Also:
    RequirementType, Constants
    • Constructor Detail

      • Requirement

        public Requirement​(@NotNull
                           String propertyName,
                           @Nullable
                           String propertyValue,
                           @NotNull
                           RequirementType type)
        Constructs a requirement with no id.
        Parameters:
        propertyName - The name of the property the requirement applies to.
        propertyValue - The value, limiting the value of the property according to the requirement type. May be null in case the requirement type does not demand any value.
        type - Requirement type.
      • Requirement

        public Requirement​(@NotNull
                           String id,
                           @NotNull
                           String propertyName,
                           @Nullable
                           String propertyValue,
                           @NotNull
                           RequirementType type)
        Constructs a requirement with the id provided
        Parameters:
        id - Requirement id.
        propertyName - The name of the property the requirement applies to
        propertyValue - The value, limiting the value of the property according to the requirement type. May be null in case the requirement type does not demand any value.
        type - Requirement type.
    • Method Detail

      • match

        public boolean match​(@NotNull
                             Map<String,​String> properties,
                             boolean ignoreCaseForEnv)
        Checks if a number of properties match the requirement.
        Parameters:
        properties - Properties name-value map.
        ignoreCaseForEnv - Indicates if character case must be ignored for properties whose name starts with "env."
        Returns:
        true if the properties match the requirement.
      • getPropertyName

        @NotNull
        public String getPropertyName()
        Property name getter.
        Returns:
        The name of a property to which the requirement is applied
      • getId

        @Nullable
        public String getId()
        Returns:
        Requirement id if this requirement has it
        Since:
        10.0
      • getType

        @NotNull
        public RequirementType getType()
        Requirement type getter.
        Returns:
        Requirement type object
      • getPropertyValue

        @Nullable
        public String getPropertyValue()
        Requirement value getter. If the requirement type demands for a value (e.g. "equals"), this method returns it.
        Returns:
        Requirement value if applicable. Null otherwise.
      • getUserDescription

        public String getUserDescription()
        Returns:
        user-readable description of the requirement
        Since:
        2020.1
      • equals

        public boolean equals​(Object o)
        Compares the requirement with another one.
        Overrides:
        equals in class Object
        Parameters:
        o - Another requirement.
        Returns:
        True if the requirements are identical in terms of both ids and other fields. False otherwise.
      • isSimilarTo

        public boolean isSimilarTo​(Requirement req)
        Checks if another requirement is equal to this ignoring the difference in ids (if any)
        Parameters:
        req - Another requirement
        Returns:
        true if the requirement objects are equal (ignoring ids)
        Since:
        10.0
      • hashCode

        public int hashCode()
        Calculates the requirement object hash code.
        Overrides:
        hashCode in class Object
        Returns:
        Hash code
      • newPropertyName

        public Requirement newPropertyName​(String newName)
        Creates a copy of this requirement with a new name.
        Parameters:
        newName - New requirement name
        Returns:
        New instance of Requirement