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.Object

A 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 logical `AND` operator. That is: all constraints must pass for the constraint to be considered valid.

### Field Summary

Fields
`static ConstraintParser.Constraint` `NONE`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `check​(ITokenProvider environment)` Checks the current token against the environment and throws a `ConstraintViolationException` if the constraint is invalid
`int` `getMax()`
`int` `getMin()`
`java.lang.String` `getRangeHumanReadable()` Gets a human-readable description of the range expressed by this constraint
`java.lang.String` `getToken()`
`java.lang.String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### 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 a `ConstraintViolationException` if 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:
  `toString` in class `java.lang.Object`