Class Scope
java.lang.Object
com.codebarrel.automation.api.config.Scope
A set of methods to help determine the scope of a rule or the type of a rule restriction.
Ideally these would live on RuleConfigBean and ProjectAssociationBean but that cannot happen until the big split and the -api project
is merged back in. Until that time they live here. This should be all you need so think twice before making any changes :)
-
Method Summary
Modifier and TypeMethodDescriptiongetProjectIdsFromProjectRestrictions(com.codebarrel.automation.api.config.RuleConfigBean rule) Filters restrictions to just project instance restrictions and then returns just the project id of each restrictiongetProjectTypesFromProjectRestrictions(com.codebarrel.automation.api.config.RuleConfigBean rule) Filters restrictions to just project instance restrictions and then returns just the project type of each restrictionstatic booleanisGlobalRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks to see if the rule applies to any project (it has no restrictions at all).static booleanisMultiProjectRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks whether the rule is restricted to more than one project instancestatic booleanisProjectInRuleRestrictions(com.codebarrel.automation.api.config.RuleConfigBean rule, String projectId) Checks to see if a rule contains a restriction on a particular projectprotected static booleanisProjectRestriction(com.codebarrel.automation.api.config.ProjectAssociationBean projectAssociation) Indicates if the project association restricts based on a specific projectstatic booleanisProjectTypeRestriction(com.codebarrel.automation.api.config.ProjectAssociationBean projectAssociation) Indicates if the project association restricts based on just the project typestatic booleanisProjectTypeRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks to see if the rule is restricted to one or more project typesstatic booleanisSingleOrMultiProjectRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Convenience and efficiency method, this is the same as calling isSingleProjectRule || isMultiProjectRulestatic booleanisSingleProjectRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks whether the rule is restricted to exactly one project instancestatic booleanisSingleProjectRuleForProject(com.codebarrel.automation.api.config.RuleConfigBean rule, String projectId) Checks whether the rule is restricted to just the specified project
-
Method Details
-
isSingleProjectRule
public static boolean isSingleProjectRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks whether the rule is restricted to exactly one project instance- Parameters:
rule- The rule to check scope for- Returns:
- true if the rule is single project, or false otherwise
-
isSingleProjectRuleForProject
public static boolean isSingleProjectRuleForProject(com.codebarrel.automation.api.config.RuleConfigBean rule, String projectId) Checks whether the rule is restricted to just the specified project- Parameters:
rule- The rule to check scope for- Returns:
- true if the rule is restricted to just the specified project, or false otherwise
-
isMultiProjectRule
public static boolean isMultiProjectRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks whether the rule is restricted to more than one project instance- Parameters:
rule- The rule to check scope for- Returns:
- true if the rule is multi project, or false otherwise
-
isProjectTypeRule
public static boolean isProjectTypeRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks to see if the rule is restricted to one or more project types- Parameters:
rule- The rule to check scope for- Returns:
- true if the rule is project type restricted, or false otherwise
-
isGlobalRule
public static boolean isGlobalRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Checks to see if the rule applies to any project (it has no restrictions at all).- Parameters:
rule- The rule to check scope for- Returns:
- true if the rule has zero restrictions, or false otherwise
-
isSingleOrMultiProjectRule
public static boolean isSingleOrMultiProjectRule(com.codebarrel.automation.api.config.RuleConfigBean rule) Convenience and efficiency method, this is the same as calling isSingleProjectRule || isMultiProjectRule- Parameters:
rule- The rule to check scope for- Returns:
- true if the rule has one or more project instance restrictions, or false otherwise
-
isProjectTypeRestriction
public static boolean isProjectTypeRestriction(com.codebarrel.automation.api.config.ProjectAssociationBean projectAssociation) Indicates if the project association restricts based on just the project type- Parameters:
projectAssociation- Association to check- Returns:
- true if the association is restricting by type, or false otherwise
-
getProjectIdsFromProjectRestrictions
public static Set<String> getProjectIdsFromProjectRestrictions(@Nullable com.codebarrel.automation.api.config.RuleConfigBean rule) Filters restrictions to just project instance restrictions and then returns just the project id of each restriction- Parameters:
rule- The rule to check scope for- Returns:
- a set of project ids, or an empty set if there was nothing to transform
-
getProjectTypesFromProjectRestrictions
public static Set<String> getProjectTypesFromProjectRestrictions(@Nullable com.codebarrel.automation.api.config.RuleConfigBean rule) Filters restrictions to just project instance restrictions and then returns just the project type of each restriction- Parameters:
rule- The rule to check scope for- Returns:
- a set of project types, or an empty set if there was nothing to transform
-
isProjectInRuleRestrictions
public static boolean isProjectInRuleRestrictions(com.codebarrel.automation.api.config.RuleConfigBean rule, String projectId) Checks to see if a rule contains a restriction on a particular project- Parameters:
rule- The rule to checkprojectId- The project Id to look for- Returns:
- true if the rule includes a restriction on this project, or false otherwise
-
isProjectRestriction
protected static boolean isProjectRestriction(com.codebarrel.automation.api.config.ProjectAssociationBean projectAssociation) Indicates if the project association restricts based on a specific project- Parameters:
projectAssociation- Association to check- Returns:
- true if the association is restricting by a specific project, or false otherwise
-