Class Requirement


  • public final class Requirement
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      Requirement​(java.lang.String id, java.lang.String propertyName, java.lang.String propertyValue, RequirementType type)
      Constructs a requirement with the id provided
      Requirement​(java.lang.String propertyName, java.lang.String propertyValue, RequirementType type)
      Constructs a requirement with no id.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Compares the requirement with another one.
      java.lang.String getId()  
      java.lang.String getPropertyName()
      Property name getter.
      java.lang.String getPropertyValue()
      Requirement value getter.
      RequirementType getType()
      Requirement type getter.
      java.lang.String getUserDescription()  
      int hashCode()
      Calculates the requirement object hash code.
      boolean isSimilarTo​(Requirement req)
      Checks if another requirement is equal to this ignoring the difference in ids (if any)
      boolean match​(java.util.Map<java.lang.String,​java.lang.String> properties, boolean ignoreCaseForEnv)
      Checks if a number of properties match the requirement.
      Requirement newPropertyName​(java.lang.String newName)
      Creates a copy of this requirement with a new name.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Requirement

        public Requirement​(@NotNull
                           java.lang.String propertyName,
                           @Nullable
                           java.lang.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
                           java.lang.String id,
                           @NotNull
                           java.lang.String propertyName,
                           @Nullable
                           java.lang.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
                             java.util.Map<java.lang.String,​java.lang.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 java.lang.String getPropertyName()
        Property name getter.
        Returns:
        The name of a property to which the requirement is applied
      • getId

        @Nullable
        public java.lang.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 java.lang.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 java.lang.String getUserDescription()
        Returns:
        user-readable description of the requirement
        Since:
        2020.1
      • equals

        public boolean equals​(java.lang.Object o)
        Compares the requirement with another one.
        Overrides:
        equals in class java.lang.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 java.lang.Object
        Returns:
        Hash code
      • newPropertyName

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object