Interface SymbolicValue
-
- All Known Subinterfaces:
SymbolicValue.SymAnnot
- All Known Implementing Classes:
SymbolicValue.SymArray
,SymbolicValue.SymClass
,SymbolicValue.SymEnum
,SymbolicValue.SymValue
public interface SymbolicValue
Structure to represent constant values of annotations symbolically. Annotations may contain:- Primitive or string values:
SymbolicValue.SymValue
- Enum constants:
SymbolicValue.SymEnum
- Class instances:
SymbolicValue.SymClass
- Other annotations:
SymbolicValue.SymAnnot
- Arrays of the above, of dimension 1:
SymbolicValue.SymArray
Any other values, including the null reference, are unsupported and cannot be represented by this API.
Currently the public API allows comparing the values to an actual java value that you compiled against (
valueEquals(Object)
). This may be improved later to allow comparing values without needing them in the compile classpath.This is a sealed interface and should not be implemented by clients.
Note: the point of this api is to enable comparisons between values, not deep introspection into values. This is why there are very few getter methods, except in
SymbolicValue.SymAnnot
, which is the API point used byAnnotableSymbol
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SymbolicValue.SymAnnot
Symbolic representation of an annotation.static class
SymbolicValue.SymArray
An array of values.static class
SymbolicValue.SymClass
Represents a class constant.static class
SymbolicValue.SymEnum
Symbolic representation of an enum constant.static class
SymbolicValue.SymValue
Represents a primitive or string value.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
equals(Object o)
Returns true if this value is equal to the other one.static @Nullable SymbolicValue
of(TypeSystem ts, Object value)
Returns a symbolic value for the given java object Returns an annotation element for the given java value.boolean
valueEquals(Object o)
Returns true if this symbolic value represents the same value as the given object.
-
-
-
Method Detail
-
valueEquals
boolean valueEquals(Object o)
Returns true if this symbolic value represents the same value as the given object. If the parameter is null, returns false.
-
equals
boolean equals(Object o)
Returns true if this value is equal to the other one. The parameter must be aSymbolicValue
of the same type. UsevalueEquals(Object)
to compare to a java object.
-
of
static @Nullable SymbolicValue of(TypeSystem ts, Object value)
Returns a symbolic value for the given java object Returns an annotation element for the given java value. Returns null if the value cannot be an annotation element or cannot be constructed.
-
-