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.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable ModelReturns the wrapped value if modeled (i.e,isModeled()is true) or null, throws if called on a non-modeled and non-null value.default ModelReturns the wrapped value if modeled (i.e,isModeled()is true), throws if called on a non-modeled value.default @Nullable ObjectReturns the wrapped value if precise (i.e,isPrecise()is true), throws if called on a non-precise value.@Nullable StringgetType()Returns the type of the tracked value.default booleanisInstanceOf(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).booleanWhether the wrapped value is modeled.booleanisNull()Whether the wrapped value is null.default booleanWhether the wrapped value is exactly of a type.default booleanisOfTypeAndNotNull(@NotNull String type) Whether the wrapped value is exactly of a type and hasn't a null value.booleanWhether the wrapped value is precise.
-
Method Details
-
getType
Returns the type of the tracked value. This is the most specific type the analysis can infer for the value.- Returns:
- the type of the wrapped value. In internal format (e.g., "Ljava/lang/String;").
-
isNull
boolean isNull()Whether the wrapped value is null.getPreciseValue()returns null in this case. -
isModeled
boolean isModeled()Whether the wrapped value is modeled.getModeledValue()returns an instance ofModelin this case. -
isPrecise
boolean isPrecise()Whether the wrapped value is precise.getPreciseValue()returns an object with the exact value in this case. -
isOfType
Whether the wrapped value is exactly of a type. No inheritance is considered.- Parameters:
type- a type to check if it corresponds to the wrapped value's type. In internal format (e.g., "Ljava/lang/String;").
-
isOfTypeAndNotNull
Whether the wrapped value is exactly of a type and hasn't a null value. -
isInstanceOf
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).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).
- Parameters:
clazz- a class the wrapped value is checked to inherit from- Returns:
- false if clazz is null or the type of the value does not belong to the class or extends it, true otherwise
-
getPreciseValue
Returns the wrapped value if precise (i.e,isPrecise()is true), throws if called on a non-precise value. -
getModeledValue
Returns the wrapped value if modeled (i.e,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) valuesgetModeledOrNullValue()should be used. -
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.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).
-