public interface AnalyzedObject
The wrapped values can be precise (i.e., it's possible to produce the exact object) or modeled
(i.e., the value is represented by a Model
).
These two definitions are usually exclusive but this is not needed. A AnalyzedObject
backed by a Model
might be able to produce a precise value if such is its design.
Modifier and Type | Method and Description |
---|---|
default @Nullable Model |
getModeledOrNullValue()
Returns the wrapped value if modeled (i.e,
isModeled() is true) or null,
throws if called on a non-modeled and non-null value. |
default Model |
getModeledValue()
Returns the wrapped value if modeled (i.e,
isModeled() is true), throws
if called on a non-modeled value. |
default @Nullable java.lang.Object |
getPreciseValue()
Returns the wrapped value if precise (i.e,
isPrecise() is true), throws
if called on a non-precise value. |
@Nullable java.lang.String |
getType()
Returns the type of the tracked value.
|
default boolean |
isInstanceOf(Clazz clazz)
Whether "instanceof" for the given clazz would return true for the wrapped value (i.e., the
tracked value is an instance of clazz or extends/implements it).
|
boolean |
isModeled()
Whether the wrapped value is modeled.
|
boolean |
isNull()
Whether the wrapped value is null.
|
default boolean |
isOfType(@NotNull java.lang.String type)
Whether the wrapped value is exactly of a type.
|
default boolean |
isOfTypeAndNotNull(@NotNull java.lang.String type)
Whether the wrapped value is exactly of a type and hasn't a null value.
|
boolean |
isPrecise()
Whether the wrapped value is precise.
|
@Nullable @Nullable java.lang.String getType()
boolean isNull()
getPreciseValue()
returns null in
this case.boolean isModeled()
getModeledValue()
returns an
instance of Model
in this case.boolean isPrecise()
getPreciseValue()
returns an
object with the exact value in this case.default boolean isOfType(@NotNull @NotNull java.lang.String type)
type
- a type to check if it corresponds to the wrapped value's type. In internal format
(e.g., "Ljava/lang/String;").default boolean isOfTypeAndNotNull(@NotNull @NotNull java.lang.String type)
default boolean isInstanceOf(Clazz clazz)
If the tracked value is an array this checks the inheritance of the referenced class (e.g., for a String[] this is true if clazz is 'Object' since String extends Object).
clazz
- a class the wrapped value is checked to inherit from@Nullable default @Nullable java.lang.Object getPreciseValue()
isPrecise()
is true), throws
if called on a non-precise value.default Model getModeledValue()
isModeled()
is true), throws
if called on a non-modeled value.
This method should be used when a non-null modeled value is expected or when isModeled()
has been checked. If a value is expected to be modeled but can also
assume null (precise) values getModeledOrNullValue()
should be used.
@Nullable default @Nullable Model getModeledOrNullValue()
isModeled()
is true) or null,
throws if called on a non-modeled and non-null value.
This method should be used in cases where the type is known to be modeled by the analysis but null values are also possible (which are precise).