Package org.spongepowered.asm.util
Class ConstraintParser.Constraint
- java.lang.Object
-
- org.spongepowered.asm.util.ConstraintParser.Constraint
-
- Enclosing class:
- ConstraintParser
public static class ConstraintParser.Constraint extends java.lang.ObjectA constraint. Constraints are parsed from string expressions which are always of the form:<token>(<constraint>)
token is normalised to uppercase and must be provided by the environment.
constraint is an integer range specified in one of the following formats:
()
- The token value must be present in the environment, but can have any value
(1234)
- The token value must be exactly equal to
1234 (1234+) (1234-) (1234>)
- All of these variants mean the same thing, and can be read as "1234 or greater"
(<1234)
- Less than 123
(<=1234)
- Less than or equal to 1234 (equivalent to
1234<) (>1234)
- Greater than 1234
(>=1234)
- Greater than or equal to 1234 (equivalent to
1234 >) (1234-1300)
- Value must be between 1234 and 1300 (inclusive)
(1234+10)
- Value must be between 1234 and 1234+10 (1234-1244 inclusive)
All whitespace is ignored in constraint declarations. The following declarations are equivalent:
token(123-456) token ( 123 - 456 )
Multiple constraints should be separated by semicolon (
;) and are conjoined by an implied logicalANDoperator. That is: all constraints must pass for the constraint to be considered valid.
-
-
Field Summary
Fields Modifier and Type Field Description static ConstraintParser.ConstraintNONE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheck(ITokenProvider environment)Checks the current token against the environment and throws aConstraintViolationExceptionif the constraint is invalidintgetMax()intgetMin()java.lang.StringgetRangeHumanReadable()Gets a human-readable description of the range expressed by this constraintjava.lang.StringgetToken()java.lang.StringtoString()
-
-
-
Field Detail
-
NONE
public static final ConstraintParser.Constraint NONE
-
-
Method Detail
-
getToken
public java.lang.String getToken()
-
getMin
public int getMin()
-
getMax
public int getMax()
-
check
public void check(ITokenProvider environment) throws org.spongepowered.asm.util.throwables.ConstraintViolationException
Checks the current token against the environment and throws aConstraintViolationExceptionif the constraint is invalid- Parameters:
environment- environment to fetch constraints- Throws:
org.spongepowered.asm.util.throwables.ConstraintViolationException- if constraint is not valid
-
getRangeHumanReadable
public java.lang.String getRangeHumanReadable()
Gets a human-readable description of the range expressed by this constraint
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-