Interface CoreFactory

All Known Implementing Classes:

public interface CoreFactory
This interface defines the core creation methods for the meta-model (to be implemented so that Spoon can manipulate other meta-model implementations).

Important: a required post-condition for all the created elements is that the factory (see FactoryAccessor.getFactory()) is correctly initialized with the main factory returned by getMainFactory(), which cannot be null.

  • Method Details

    • clone

      <T extends CtElement> T clone(T element)
      Recursively clones a given element of the metamodel and all its child elements.
      Type Parameters:
      T - the element's type
      element - the element
      a clone of element
      See Also:
    • createAnnotation

      <A extends Annotation> CtAnnotation<A> createAnnotation()
      Creates an annotation.
    • createAnnotationType

      <T extends Annotation> CtAnnotationType<T> createAnnotationType()
      Creates an annotation type.
    • createAnonymousExecutable

      CtAnonymousExecutable createAnonymousExecutable()
      Creates an anonymous executable.
    • createArrayRead

      <T> CtArrayRead<T> createArrayRead()
      Creates an array read access expression.
    • createArrayWrite

      <T> CtArrayWrite<T> createArrayWrite()
      Creates an array write access expression.
    • createArrayTypeReference

      <T> CtArrayTypeReference<T> createArrayTypeReference()
      Creates an array type reference.
    • createAssert

      <T> CtAssert<T> createAssert()
      Creates an assert statement.
    • createAssignment

      <T,​ A extends T> CtAssignment<T,​A> createAssignment()
      Creates an assignment expression.
    • createBinaryOperator

      <T> CtBinaryOperator<T> createBinaryOperator()
      Creates a binary operator.
    • createBlock

      <R> CtBlock<R> createBlock()
      Creates a block.
    • createBreak

      CtBreak createBreak()
      Creates a break statement.
    • createCase

      <S> CtCase<S> createCase()
      Creates a case clause.
    • createCatch

      CtCatch createCatch()
      Creates a catch clause.
    • createClass

      <T> CtClass<T> createClass()
      Creates a class.
    • createTypeParameter

      CtTypeParameter createTypeParameter()
      Creates a type parameter declaration.
    • createConditional

      <T> CtConditional<T> createConditional()
      Creates a conditional expression (boolExpr?ifTrue:ifFalse).
    • createConstructor

      <T> CtConstructor<T> createConstructor()
      Creates a constructor.
    • createInvisibleArrayConstructor

      <T> CtConstructor<T> createInvisibleArrayConstructor()
      Creates an invisible array constructor.
    • createContinue

      CtContinue createContinue()
      Creates a continue statement.
    • createDo

      CtDo createDo()
      Creates a do loop.
    • createEnum

      <T extends Enum<?>> CtEnum<T> createEnum()
      Creates an enum.
    • createExecutableReference

      <T> CtExecutableReference<T> createExecutableReference()
      Creates an executable reference.
    • createField

      <T> CtField<T> createField()
      Creates a field.
    • createEnumValue

      <T> CtEnumValue<T> createEnumValue()
      Creates an enum value.
    • createFieldRead

      <T> CtFieldRead<T> createFieldRead()
      Creates a field read access.
    • createFieldWrite

      <T> CtFieldWrite<T> createFieldWrite()
      Creates a field write access.
    • createThisAccess

      <T> CtThisAccess<T> createThisAccess()
      Creates an access expression to this.
    • createSuperAccess

      <T> CtSuperAccess<T> createSuperAccess()
      Creates an access expression to super.
    • createFieldReference

      <T> CtFieldReference<T> createFieldReference()
      Creates a field reference.
    • createFor

      CtFor createFor()
      Creates a for loop.
    • createForEach

      CtForEach createForEach()
      Creates a foreach loop.
    • createIf

      CtIf createIf()
      Creates an if statement.
    • createInterface

      <T> CtInterface<T> createInterface()
      Creates an interface.
    • createInvocation

      <T> CtInvocation<T> createInvocation()
      Creates an invocation expression.
    • createLiteral

      <T> CtLiteral<T> createLiteral()
      Creates a literal expression.
    • createLocalVariable

      <T> CtLocalVariable<T> createLocalVariable()
      Creates a local variable declaration statement.
    • createLocalVariableReference

      <T> CtLocalVariableReference<T> createLocalVariableReference()
      Creates a local variable reference.
    • createCatchVariable

      <T> CtCatchVariable<T> createCatchVariable()
      Creates a catch variable declaration statement.
    • createCatchVariableReference

      <T> CtCatchVariableReference<T> createCatchVariableReference()
      Creates a catch variable reference.
    • createMethod

      <T> CtMethod<T> createMethod()
      Creates a method.
    • createAnnotationMethod

      <T> CtAnnotationMethod<T> createAnnotationMethod()
      Creates an annotation method.
    • createNewArray

      <T> CtNewArray<T> createNewArray()
      Creates a new array expression.
    • createConstructorCall

      <T> CtConstructorCall<T> createConstructorCall()
      Creates a constructor call expression. Example to build "new Foo()":
           CtConstructorCall call = spoon.getFactory().Core().createConstructorCall();
    • createNewClass

      <T> CtNewClass<T> createNewClass()
      Creates a new anonymous class expression.
    • createLambda

      <T> CtLambda<T> createLambda()
      Creates a new anonymous method expression.
    • createExecutableReferenceExpression

      <T,​ E extends CtExpression<?>> CtExecutableReferenceExpression<T,​E> createExecutableReferenceExpression()
      Creates a new executable reference expression.
    • createOperatorAssignment

      <T,​ A extends T> CtOperatorAssignment<T,​A> createOperatorAssignment()
      Creates a new operator assignment (like +=).
    • createPackage

      CtPackage createPackage()
      Creates a package.
    • createPackageReference

      CtPackageReference createPackageReference()
      Creates a package reference.
    • createParameter

      <T> CtParameter<T> createParameter()
      Creates a parameter.
    • createParameterReference

      <T> CtParameterReference<T> createParameterReference()
      Creates a parameter reference.
    • createReturn

      <R> CtReturn<R> createReturn()
      Creates a return statement.
    • createSourcePosition

      SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int[] lineSeparatorPositions)
      Creates a source position.
    • createPartialSourcePosition

      SourcePosition createPartialSourcePosition(CompilationUnit compilationUnit)
      Creates a source position that points to the given compilation unit
    • createCompoundSourcePosition

      CompoundSourcePosition createCompoundSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int declarationStart, int declarationEnd, int[] lineSeparatorPositions)
      Creates a compound source position.
    • createDeclarationSourcePosition

      DeclarationSourcePosition createDeclarationSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int modifierStart, int modifierEnd, int declarationStart, int declarationEnd, int[] lineSeparatorPositions)
      Creates a declaration source position.
    • createBodyHolderSourcePosition

      BodyHolderSourcePosition createBodyHolderSourcePosition(CompilationUnit compilationUnit, int nameSource, int nameEnd, int modifierStart, int modifierEnd, int declarationStart, int declarationEnd, int bodyStart, int bodyEnd, int[] lineSeparatorPositions)
      Creates a body holder source position.
    • createStatementList

      <R> CtStatementList createStatementList()
      Creates a statement list.
    • createSwitch

      <S> CtSwitch<S> createSwitch()
      Creates a switch statement.
    • createSwitchExpression

      <T,​ S> CtSwitchExpression<T,​S> createSwitchExpression()
      Creates a switch expression.
    • createSynchronized

      CtSynchronized createSynchronized()
      Creates a synchronized statement.
    • createThrow

      CtThrow createThrow()
      Creates a throw statement.
    • createTry

      CtTry createTry()
      Creates a try block.
    • createTryWithResource

      CtTryWithResource createTryWithResource()
      Creates a try with resource block.
    • createTypeParameterReference

      CtTypeParameterReference createTypeParameterReference()
      Creates a type parameter reference.
    • createWildcardReference

      CtWildcardReference createWildcardReference()
      Creates a wildcard reference.
    • createIntersectionTypeReference

      <T> CtIntersectionTypeReference<T> createIntersectionTypeReference()
      Creates an intersection type reference.
    • createTypeReference

      <T> CtTypeReference<T> createTypeReference()
      Creates a type reference.
    • createTypeAccess

      <T> CtTypeAccess<T> createTypeAccess()
      Creates a type access expression.
    • createUnaryOperator

      <T> CtUnaryOperator<T> createUnaryOperator()
      Creates a unary operator expression.
    • createVariableRead

      <T> CtVariableRead<T> createVariableRead()
      Creates a variable read expression.
    • createVariableWrite

      <T> CtVariableWrite<T> createVariableWrite()
      Creates a variable write expression.
    • createWhile

      CtWhile createWhile()
      Creates a while loop.
    • createCodeSnippetExpression

      <T> CtCodeSnippetExpression<T> createCodeSnippetExpression()
      Creates a code snippet expression.
    • createCodeSnippetStatement

      CtCodeSnippetStatement createCodeSnippetStatement()
      Creates a code snippet statement.
    • createComment

      CtComment createComment()
      Creates a comment.
    • createJavaDoc

      CtJavaDoc createJavaDoc()
      Creates a javadoc comment.
    • createJavaDocTag

      CtJavaDocTag createJavaDocTag()
      Creates a javadoc tag.
    • createImport

      CtImport createImport()
      Creates an import.
    • createUnresolvedImport

      CtImport createUnresolvedImport()
      Creates an unresolved import. CtUnresolvedImport stores the original content of the imort as a String in order to be able to restituate it when pretty printing.
    • createPackageDeclaration

      CtPackageDeclaration createPackageDeclaration()
      Creates a package declaration.
    • getMainFactory

      Factory getMainFactory()
      Gets the main factory of that core factory (cannot be null).
    • setMainFactory

      void setMainFactory(Factory mainFactory)
      Sets the main factory of that core factory.
    • createCompilationUnit

      CompilationUnit createCompilationUnit()
      Creates a compilation unit.
    • createAnnotationFieldAccess

      <T> CtAnnotationFieldAccess<T> createAnnotationFieldAccess()
      Create an access to annotation value
    • createUnboundVariableReference

      <T> CtUnboundVariableReference<T> createUnboundVariableReference()
      Creates an unbound variable used in noclasspath.
    • create

      CtElement create(Class<? extends CtElement> klass)
      Creates an instance of the concrete metamodel class given as parameter. This is in particular useful when one uses reflection.
    • createTypeMemberWildcardImportReference

      CtTypeMemberWildcardImportReference createTypeMemberWildcardImportReference()
      Create a wildcard reference to a type member, used in a static import
    • createModule

      CtModule createModule()
      Creates a Java 9 module
    • createModuleReference

      CtModuleReference createModuleReference()
      Creates a reference to a Java 9 module
    • createModuleRequirement

      CtModuleRequirement createModuleRequirement()
      Creates a "requires" directive for a Java 9 module file
    • createPackageExport

      CtPackageExport createPackageExport()
      Creates a "export" directive for a Java 9 module file
    • createProvidedService

      CtProvidedService createProvidedService()
      Creates a "provides" directive for a Java 9 module file
    • createUsedService

      CtUsedService createUsedService()
      Creates a "uses" directive for a Java 9 module file
    • createYieldStatement

      CtYieldStatement createYieldStatement()
      Creates a yield statement
    • createTextBlock

      CtTextBlock createTextBlock()
      Creates a TextBlock String Literal
    • createTypePattern

      CtTypePattern createTypePattern()
      Creates a Type Pattern
      a new Type Pattern instance.
    • createRecord

      CtRecord createRecord()
      Creates a record.
      the created record.
    • createRecordComponent

      CtRecordComponent createRecordComponent()
      Creates a record component.
      the created record component.