Class Requirement
- java.lang.Object
-
- jetbrains.buildServer.requirements.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 withConstants.SYSTEM_PREFIX, environment variable name should be prefixed withConstants.ENV_PREFIXThere are various Requirement types, such as "exists", "match", "contains" and so on.- See Also:
RequirementType,Constants
-
-
Constructor Summary
Constructors Constructor Description Requirement(String id, String propertyName, String propertyValue, RequirementType type)Constructs a requirement with the id providedRequirement(String propertyName, String propertyValue, RequirementType type)Constructs a requirement with no id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Compares the requirement with another one.StringgetId()StringgetPropertyName()Property name getter.StringgetPropertyValue()Requirement value getter.RequirementTypegetType()Requirement type getter.StringgetUserDescription()inthashCode()Calculates the requirement object hash code.booleanisSimilarTo(Requirement req)Checks if another requirement is equal to this ignoring the difference in ids (if any)booleanmatch(Map<String,String> properties, boolean ignoreCaseForEnv)Checks if a number of properties match the requirement.RequirementnewPropertyName(String newName)Creates a copy of this requirement with a new name.StringtoString()
-
-
-
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 topropertyValue- 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.
-
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.
-
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
-
-