Class JavaParserRecordDeclaration

  • All Implemented Interfaces:
    com.github.javaparser.resolution.declarations.AssociableToAST, com.github.javaparser.resolution.declarations.HasAccessSpecifier, com.github.javaparser.resolution.declarations.ResolvedDeclaration, com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration, com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration, com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration, com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable, com.github.javaparser.resolution.logic.MethodResolutionCapability, MethodUsageResolutionCapability, SymbolResolutionCapability

    public class JavaParserRecordDeclaration
    extends AbstractTypeDeclaration
    implements com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration, com.github.javaparser.resolution.logic.MethodResolutionCapability, MethodUsageResolutionCapability, SymbolResolutionCapability
    Heavily based on JavaParserClassDeclaration
    Author:
    Federico Tomassetti
    • Field Summary

      • Fields inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration

        breadthFirstFunc, depthFirstFunc, JAVA_IO_SERIALIZABLE, JAVA_LANG_COMPARABLE, JAVA_LANG_ENUM, JAVA_LANG_OBJECT, JAVA_LANG_RECORD
    • Constructor Summary

      Constructors 
      Constructor Description
      JavaParserRecordDeclaration​(com.github.javaparser.ast.body.RecordDeclaration wrappedNode, com.github.javaparser.resolution.TypeSolver typeSolver)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      com.github.javaparser.ast.AccessSpecifier accessSpecifier()  
      boolean canBeAssignedTo​(com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration other)  
      java.util.Optional<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> containerType()  
      boolean equals​(java.lang.Object o)  
      java.util.List<com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration> getAllFields()
      This method returns both the ResolvedFieldDeclarations for the explicit static fields declared in the record and non-static private fields corresponding to the record parameters.
      java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getAllInterfaces()  
      java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getAllSuperClasses()  
      java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getAncestors​(boolean acceptIncompleteList)  
      java.lang.String getClassName()  
      java.util.List<com.github.javaparser.resolution.declarations.ResolvedConstructorDeclaration> getConstructors()  
      com.github.javaparser.resolution.Context getContext()
      Deprecated.
      java.util.Set<com.github.javaparser.resolution.declarations.ResolvedAnnotationDeclaration> getDeclaredAnnotations()  
      java.util.Set<com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration> getDeclaredMethods()
      This method returns both the explicit methods declared in the record and the implicit getter methods for the record parameters.
      java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getInterfaces()  
      java.lang.String getName()  
      java.lang.String getPackageName()  
      java.lang.String getQualifiedName()  
      java.util.Optional<com.github.javaparser.resolution.types.ResolvedReferenceType> getSuperClass()  
      java.util.List<com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration> getTypeParameters()  
      com.github.javaparser.resolution.types.ResolvedType getUsage​(com.github.javaparser.ast.Node node)  
      com.github.javaparser.ast.body.RecordDeclaration getWrappedNode()
      Returns the JavaParser node associated with this JavaParserClassDeclaration.
      boolean hasDirectlyAnnotation​(java.lang.String canonicalName)  
      int hashCode()  
      java.util.Set<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> internalTypes()  
      boolean isAssignableBy​(com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration other)  
      boolean isAssignableBy​(com.github.javaparser.resolution.types.ResolvedType type)  
      com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration> solveMethod​(java.lang.String name, java.util.List<com.github.javaparser.resolution.types.ResolvedType> parameterTypes)  
      com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration> solveMethod​(java.lang.String name, java.util.List<com.github.javaparser.resolution.types.ResolvedType> argumentsTypes, boolean staticOnly)  
      java.util.Optional<com.github.javaparser.resolution.MethodUsage> solveMethodAsUsage​(java.lang.String name, java.util.List<com.github.javaparser.resolution.types.ResolvedType> argumentTypes, com.github.javaparser.resolution.Context invocationContext, java.util.List<com.github.javaparser.resolution.types.ResolvedType> typeParameters)  
      com.github.javaparser.resolution.model.SymbolReference<? extends com.github.javaparser.resolution.declarations.ResolvedValueDeclaration> solveSymbol​(java.lang.String name, com.github.javaparser.resolution.TypeSolver typeSolver)  
      com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration> solveType​(java.lang.String name)
      Deprecated.
      java.util.Optional<com.github.javaparser.ast.Node> toAst()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.github.javaparser.resolution.declarations.AssociableToAST

        toAst
      • Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedDeclaration

        asEnumConstant, asField, asMethod, asParameter, asTypePattern, hasName, isArrayLength, isEnumConstant, isField, isMethod, isParameter, isTypePattern, isVariable
      • Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration

        asRecord, isRecord
      • Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration

        asReferenceType, findTypeParameter, getAllAncestors, getAllAncestors, getAllMethods, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredAnnotation, getDeclaredFields, getField, getVisibleField, getVisibleFields, hasAnnotation, hasField, hasVisibleField, isFunctionalInterface, isInheritedAnnotation, isJavaLangEnum, isJavaLangObject, isJavaLangRecord, isReferenceType
      • Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration

        asAnnotation, asClass, asEnum, asInterface, asType, asTypeParameter, getId, getInternalType, hasInternalType, isAnnotation, isAnonymousClass, isClass, isEnum, isInterface, isType, isTypeParameter
      • Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable

        isGeneric
    • Constructor Detail

      • JavaParserRecordDeclaration

        public JavaParserRecordDeclaration​(com.github.javaparser.ast.body.RecordDeclaration wrappedNode,
                                           com.github.javaparser.resolution.TypeSolver typeSolver)
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getAllFields

        public java.util.List<com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration> getAllFields()
        This method returns both the ResolvedFieldDeclarations for the explicit static fields declared in the record and non-static private fields corresponding to the record parameters. This is done to make the fields of a record consistent across the various models (since the record parameters are considered fields by the Java compiler and runtime).
        Specified by:
        getAllFields in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • solveMethod

        public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration> solveMethod​(java.lang.String name,
                                                                                                                                                           java.util.List<com.github.javaparser.resolution.types.ResolvedType> parameterTypes)
      • solveMethodAsUsage

        public java.util.Optional<com.github.javaparser.resolution.MethodUsage> solveMethodAsUsage​(java.lang.String name,
                                                                                                   java.util.List<com.github.javaparser.resolution.types.ResolvedType> argumentTypes,
                                                                                                   com.github.javaparser.resolution.Context invocationContext,
                                                                                                   java.util.List<com.github.javaparser.resolution.types.ResolvedType> typeParameters)
        Specified by:
        solveMethodAsUsage in interface MethodUsageResolutionCapability
      • getContext

        @Deprecated
        public com.github.javaparser.resolution.Context getContext()
        Deprecated.
        This method is deprecated because the context is an implementation detail that should not be exposed. Ideally this method should become private. For this reason all further usages of this method are discouraged.
      • getUsage

        public com.github.javaparser.resolution.types.ResolvedType getUsage​(com.github.javaparser.ast.Node node)
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface com.github.javaparser.resolution.declarations.ResolvedDeclaration
      • getSuperClass

        public java.util.Optional<com.github.javaparser.resolution.types.ResolvedReferenceType> getSuperClass()
        Specified by:
        getSuperClass in interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration
      • getInterfaces

        public java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getInterfaces()
        Specified by:
        getInterfaces in interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration
      • getAllSuperClasses

        public java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getAllSuperClasses()
        Specified by:
        getAllSuperClasses in interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration
      • getAllInterfaces

        public java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getAllInterfaces()
        Specified by:
        getAllInterfaces in interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration
      • getConstructors

        public java.util.List<com.github.javaparser.resolution.declarations.ResolvedConstructorDeclaration> getConstructors()
        Specified by:
        getConstructors in interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration
        Specified by:
        getConstructors in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • hasDirectlyAnnotation

        public boolean hasDirectlyAnnotation​(java.lang.String canonicalName)
        Specified by:
        hasDirectlyAnnotation in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • getDeclaredAnnotations

        public java.util.Set<com.github.javaparser.resolution.declarations.ResolvedAnnotationDeclaration> getDeclaredAnnotations()
        Specified by:
        getDeclaredAnnotations in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • getPackageName

        public java.lang.String getPackageName()
        Specified by:
        getPackageName in interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
      • getClassName

        public java.lang.String getClassName()
        Specified by:
        getClassName in interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Specified by:
        getQualifiedName in interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
      • isAssignableBy

        public boolean isAssignableBy​(com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration other)
        Specified by:
        isAssignableBy in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • isAssignableBy

        public boolean isAssignableBy​(com.github.javaparser.resolution.types.ResolvedType type)
        Specified by:
        isAssignableBy in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • canBeAssignedTo

        public boolean canBeAssignedTo​(com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration other)
        Specified by:
        canBeAssignedTo in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • solveType

        @Deprecated
        public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration> solveType​(java.lang.String name)
        Deprecated.
        Resolution should move out of declarations, so that they are pure declarations and the resolution should work for JavaParser, Reflection and Javassist classes in the same way and not be specific to the three implementations.
      • solveMethod

        public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration> solveMethod​(java.lang.String name,
                                                                                                                                                           java.util.List<com.github.javaparser.resolution.types.ResolvedType> argumentsTypes,
                                                                                                                                                           boolean staticOnly)
        Specified by:
        solveMethod in interface com.github.javaparser.resolution.logic.MethodResolutionCapability
      • solveSymbol

        public com.github.javaparser.resolution.model.SymbolReference<? extends com.github.javaparser.resolution.declarations.ResolvedValueDeclaration> solveSymbol​(java.lang.String name,
                                                                                                                                                                    com.github.javaparser.resolution.TypeSolver typeSolver)
        Specified by:
        solveSymbol in interface SymbolResolutionCapability
        Parameters:
        name - Field / symbol name.
        typeSolver - Symbol solver to resolve type usage.
        Returns:
        Symbol reference of the resolved value.
      • getAncestors

        public java.util.List<com.github.javaparser.resolution.types.ResolvedReferenceType> getAncestors​(boolean acceptIncompleteList)
        Specified by:
        getAncestors in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • getDeclaredMethods

        public java.util.Set<com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration> getDeclaredMethods()
        This method returns both the explicit methods declared in the record and the implicit getter methods for the record parameters. This is done for consistency across the various models.
        Specified by:
        getDeclaredMethods in interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
      • getTypeParameters

        public java.util.List<com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration> getTypeParameters()
        Specified by:
        getTypeParameters in interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
      • getWrappedNode

        public com.github.javaparser.ast.body.RecordDeclaration getWrappedNode()
        Returns the JavaParser node associated with this JavaParserClassDeclaration.
        Returns:
        A visitable JavaParser node wrapped by this object.
      • accessSpecifier

        public com.github.javaparser.ast.AccessSpecifier accessSpecifier()
        Specified by:
        accessSpecifier in interface com.github.javaparser.resolution.declarations.HasAccessSpecifier
      • toAst

        public java.util.Optional<com.github.javaparser.ast.Node> toAst()
        Specified by:
        toAst in interface com.github.javaparser.resolution.declarations.AssociableToAST
      • internalTypes

        public java.util.Set<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> internalTypes()
        Specified by:
        internalTypes in interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
      • containerType

        public java.util.Optional<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> containerType()
        Specified by:
        containerType in interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration