public class OffsetEquation extends Object
An OffsetEquation is mutable.
Modifier and Type | Field and Description |
---|---|
static OffsetEquation |
NEG_1 |
static OffsetEquation |
ONE |
static OffsetEquation |
ZERO |
Modifier | Constructor and Description |
---|---|
protected |
OffsetEquation(OffsetEquation other)
Create a new OffsetEquation that is a copy of the given one.
|
Modifier and Type | Method and Description |
---|---|
OffsetEquation |
copyAdd(char op,
OffsetEquation other)
Adds or subtracts the other equation to a copy of this one.
|
static OffsetEquation |
createOffsetForInt(int value)
Creates an offset equation that is only the int value specified.
|
static OffsetEquation |
createOffsetFromJavaExpression(String expressionEquation)
Creates an offset equation from the expressionEquation.
|
static OffsetEquation |
createOffsetFromNode(Node node,
AnnotationProvider factory,
char op)
Creates an offset equation from the Node.
|
static OffsetEquation |
createOffsetFromNodesValue(Node node,
ValueAnnotatedTypeFactory factory,
char op)
If node is an int value known at compile time, then the returned equation is just the int value
or if op is '-', the return equation is the negation of the int value.
|
boolean |
equals(@Nullable Object o) |
String |
getError() |
int |
getInt()
Returns the int value associated with this equation.
|
static OffsetEquation |
getIntOffsetEquation(Set<OffsetEquation> equationSet)
Returns the offset equation that is an int value or null if there isn't one.
|
boolean |
hasError() |
int |
hashCode() |
boolean |
isInt()
Returns true if this equation is a single int value.
|
boolean |
isNegativeOrZero()
Returns true if this equation is negative or zero.
|
boolean |
isNegOne()
Returns true if this equation is exactly -1.
|
boolean |
isNonNegative()
Returns true if this equation non-negative.
|
boolean |
lessThanOrEqual(OffsetEquation other)
Returns whether or not this equation is known to be less than or equal to the other equation.
|
OffsetEquation |
removeSequenceLengths(List<String> sequences)
Makes a copy of this offset and removes any added terms that are accesses to the length of the
listed sequences.
|
String |
toString() |
public static final OffsetEquation ZERO
public static final OffsetEquation NEG_1
public static final OffsetEquation ONE
protected OffsetEquation(OffsetEquation other)
other
- the OffsetEquation to copypublic boolean hasError()
public String getError()
public OffsetEquation removeSequenceLengths(List<String> sequences)
sequences
- list of sequences (arrays or strings)public OffsetEquation copyAdd(char op, OffsetEquation other)
If subtraction is specified, then every term in other is subtracted.
op
- '-' for subtraction or '+' for additionother
- equation to add or subtractpublic boolean lessThanOrEqual(OffsetEquation other)
other
- equationpublic boolean isInt()
public int getInt()
The equation may or may not have other terms. Use isInt()
to determine if the
equation is only this int value.
public boolean isNegOne()
public boolean isNonNegative()
public boolean isNegativeOrZero()
public static OffsetEquation getIntOffsetEquation(Set<OffsetEquation> equationSet)
equationSet
- a set of offset equationspublic static OffsetEquation createOffsetForInt(int value)
value
- int value of the equationpublic static OffsetEquation createOffsetFromJavaExpression(String expressionEquation)
expressionEquation
- a Java expression made up of sums and differencespublic static OffsetEquation createOffsetFromNodesValue(Node node, ValueAnnotatedTypeFactory factory, char op)
Otherwise, null is returned.
node
- the Node from which to create an offset equationfactory
- an AnnotationTypeFactoryop
- '+' or '-'public static OffsetEquation createOffsetFromNode(Node node, AnnotationProvider factory, char op)
If node is an addition or subtracted node, then this method is called recursively on the left and right hand nodes and the two equations are added/subtracted to each other depending on the value of op.
Otherwise the return equation is created by converting the node to a JavaExpression
and then added as a term to the
returned equation. If op is '-' then it is a subtracted term.
node
- the Node from which to create an offset equationfactory
- an AnnotationTypeFactoryop
- '+' or '-'