- java.lang.Object
-
- com.rezzedup.util.constants.MatchRules
-
public class MatchRules extends Object
Immutable criteria for filtering constants based on their name and other settings for aggregation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MatchRulesall(String... required)Appends required strings to the existing rules.MatchRulesany(String... optional)Appends optional strings to the existing rules.MatchRulescollections(boolean visit)Sets whether the contents contained within constant collections should be aggregated.booleanequals(@NullOr Object o)inthashCode()booleanisAggregatingFromCollections()Gets whether aggregating from the contents of constant collections is allowed by these rules or not.booleanmatches(String name)Checks if the provided name matches the criteria contained within these rules.MatchRulesnot(String... excluded)Appends excluded strings to the existing rules.static MatchRulesof()Specifies criteria for filtering constants based on their name and other settings.StringtoString()
-
-
-
Method Detail
-
of
public static MatchRules of()
Specifies criteria for filtering constants based on their name and other settings. By default, the rules will match all names but won't visit the contents of constant collections.It should be noted that since all
MatchRulesinstances are immutable, the same default instance is always returned by this method. Any additional criteria will construct entirely new instances.- Returns:
- the default immutable rules instance
-
all
public MatchRules all(String... required)
Appends required strings to the existing rules. A constant will only match this rule if its name contains all of the specified strings.- Parameters:
required- all the strings a constant name must contain in order to match- Returns:
- new instance containing the amended rules or itself if no new rules are specified
-
any
public MatchRules any(String... optional)
Appends optional strings to the existing rules. A constant will only match this rule if its name contains any (at least one) of the specified strings.- Parameters:
optional- strings a constant name is expected to contain at least one of in order to match- Returns:
- new instance containing the amended rules or itself if no new rules are specified
-
not
public MatchRules not(String... excluded)
Appends excluded strings to the existing rules. A constant will only match this rule if its name contains none of the specified strings.- Parameters:
excluded- all the strings a constant name must not contain in order to match- Returns:
- new instance containing the amended rules or itself if no new rules are specified
-
collections
public MatchRules collections(boolean visit)
Sets whether the contents contained within constant collections should be aggregated.- Parameters:
visit-trueif collections should be visited orfalseto disable- Returns:
- new instance containing the amended rules or itself if no new rules are specified
-
matches
public boolean matches(String name)
Checks if the provided name matches the criteria contained within these rules.- Parameters:
name- the name to check- Returns:
trueif the name matches, otherwisefalse
-
isAggregatingFromCollections
public boolean isAggregatingFromCollections()
Gets whether aggregating from the contents of constant collections is allowed by these rules or not.- Returns:
trueif allowed, otherwisefalse
-
-