Class SymbolReference<S extends ResolvedDeclaration>

java.lang.Object
com.github.javaparser.resolution.model.SymbolReference<S>

public class SymbolReference<S extends ResolvedDeclaration> extends Object
A reference to a symbol. It can solved or not solved. If solved the corresponding declaration will be provided.
  • Field Details

  • Constructor Details

    • SymbolReference

      private SymbolReference(@Nullable S correspondingDeclaration)
  • Method Details

    • solved

      public static <S extends ResolvedDeclaration, S2 extends S> SymbolReference<S> solved(S2 symbolDeclaration)
      Create a solve reference to the given symbol.
    • unsolved

      public static <S extends ResolvedDeclaration> SymbolReference<S> unsolved()
      Create a reference for an unsolved symbol.
      Type Parameters:
      S - The symbol reference type.
      Returns:
      The created unsolved symbol reference.
    • unsolved

      @Deprecated public static <S extends ResolvedDeclaration, S2 extends S> SymbolReference<S> unsolved(Class<S2> clazz)
      Deprecated.
      Consider using unsolved() instead.
      Create an unsolved reference specifying the type of the value expected.
    • adapt

      public static <I extends ResolvedDeclaration, O extends ResolvedDeclaration> SymbolReference<O> adapt(SymbolReference<I> ref, Class<O> clazz)
      Adapt a SymbolReference into another SymbolReference.
      Type Parameters:
      I - The Symbol Reference before adapting.
      O - The Symbol Reference after adapting.
      Parameters:
      ref - The reference to be adapted.
      clazz - The final type to be used.
      Returns:
      The adapted symbol reference.
    • getDeclaration

      public Optional<S> getDeclaration()
      Get the declaration associated with the Symbol.
      Returns:
      an Optional with a present value if the symbol is solved, otherwise an empty Optional.
    • getCorrespondingDeclaration

      public S getCorrespondingDeclaration()
      The corresponding declaration. If not solve this throws UnsupportedOperationException.
    • isSolved

      public boolean isSolved()
      Is the reference solved?
    • toString

      public String toString()
      Overrides:
      toString in class Object