Interface AnalyzedObject


  • public interface AnalyzedObject
    A class wrapping values calculated during an analysis.

    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

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method 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.
    • Method Detail

      • getType

        @Nullable
        @Nullable java.lang.String 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 of Model in this case.
      • isPrecise

        boolean isPrecise()
        Whether the wrapped value is precise. getPreciseValue() returns an object with the exact value in this case.
      • isOfType

        default boolean isOfType​(@NotNull
                                 @NotNull java.lang.String type)
        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

        default boolean isOfTypeAndNotNull​(@NotNull
                                           @NotNull java.lang.String type)
        Whether the wrapped value is exactly of a type and hasn't a null value.
      • isInstanceOf

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

        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

        @Nullable
        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.
      • getModeledValue

        default Model 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) values getModeledOrNullValue() should be used.

      • getModeledOrNullValue

        @Nullable
        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.

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