org.eclipse.xtext.xbase.jvmmodel
Class JvmTypesBuilder

java.lang.Object
  extended by org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder

@NonNullByDefault
public class JvmTypesBuilder
extends java.lang.Object

A set of factory and builder functions, used to create instances of (TypesPackage). It's meant to be used from an implementation of IJvmModelInferrer.

Author:
Sven Efftinge - Initial contribution and API, Jan Koehnlein

Nested Class Summary
static interface JvmTypesBuilder.AnnotationValueTranslator
           
 
Constructor Summary
JvmTypesBuilder()
           
 
Method Summary
 JvmTypeReference addArrayTypeDimension(JvmTypeReference componentType)
           
<T extends JvmIdentifiableElement>
T
associate(org.eclipse.emf.ecore.EObject sourceElement, T target)
          Associates a source element with a target element.
protected
<T extends org.eclipse.emf.ecore.EObject>
T
cloneAndAssociate(T original)
          Creates a deep copy of the given object and associates each copied instance with the clone.
protected
<T extends JvmTypeReference>
T
cloneAndAssociate(T original)
          Creates a deep copy of the given object and associates each copied instance with the clone.
 JvmTypeReference cloneWithProxies(JvmTypeReference typeRef)
          Creates a clone of the given JvmTypeReference without resolving any proxies.
<T extends JvmIdentifiableElement>
T
cloneWithProxies(T original)
          Creates a clone of the given JvmIdentifiableElement without resolving any proxies.
protected  JvmGenericType createJvmGenericType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)
           
 java.lang.String getDocumentation(org.eclipse.emf.ecore.EObject source)
          Retrieves the attached documentation for the given source element.
 JvmAnnotationReference getJvmAnnotationReference(XAnnotation anno)
           
protected  JvmAnnotationValue getJvmAnnotationValue(XExpression value)
           
protected
<T extends org.eclipse.emf.ecore.EObject>
T
initializeSafely(T targetElement, Procedures.Procedure1<? super T> initializer)
           
 JvmTypeReference newTypeRef(org.eclipse.emf.ecore.EObject ctx, java.lang.Class<?> clazz, JvmTypeReference... typeArgs)
          Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.
 JvmTypeReference newTypeRef(org.eclipse.emf.ecore.EObject ctx, java.lang.String typeName, JvmTypeReference... typeArgs)
          Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.
 JvmTypeReference newTypeRef(JvmDeclaredType type, JvmTypeReference... typeArgs)
          Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.
<T> boolean
operator_add(org.eclipse.emf.common.util.EList<? super T> list, java.lang.Iterable<? extends T> elements)
          Overrides the default operator_add() to ignore null elements.
<T> boolean
operator_add(org.eclipse.emf.common.util.EList<? super T> list, T element)
          Overrides the default operator_add() to ignore null elements.
protected  void removeExistingBody(JvmMember member)
           
 void setBody(JvmExecutable executable, Procedures.Procedure1<ITreeAppendable> strategy)
          Attaches the given compile strategy to the given JvmExecutable such that the compiler knows how to implement the JvmExecutable when it is translated to Java source code.
 void setBody(JvmExecutable logicalContainer, XExpression expr)
          Sets the given JvmExecutable as the logical container for the given XExpression.
protected  void setCompilationStrategy(JvmMember member, Procedures.Procedure1<ITreeAppendable> strategy)
           
 void setDocumentation(JvmIdentifiableElement jvmElement, java.lang.String documentation)
          Attaches the given documentation to the given jvmElement.
 void setInitializer(JvmField field, Procedures.Procedure1<ITreeAppendable> strategy)
          Attaches the given compile strategy to the given JvmField such that the compiler knows how to initialize the JvmField when it is translated to Java source code.
 void setInitializer(JvmField field, XExpression expr)
          Sets the given JvmField as the logical container for the given XExpression.
protected  Pair<java.lang.String,java.lang.String> splitQualifiedName(java.lang.String name)
           
 JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType)
          Creates and returns an annotation reference of the given annotation type.
 JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType, java.lang.Object value)
          Creates and returns an annotation reference of the given annotation type's name and the given value.
 JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName)
          Creates and returns an annotation reference of the given annotation type's name.
 JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName, java.lang.Object value)
          Creates and returns an annotation reference of the given annotation type's name and the given value.
 JvmAnnotationType toAnnotationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, Procedures.Procedure1<? super JvmAnnotationType> initializer)
          Creates a public annotation declaration, associated to the given sourceElement.
 JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, QualifiedName name)
          Creates a public class declaration, associated to the given sourceElement.
 JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, QualifiedName name, Procedures.Procedure1<? super JvmGenericType> initializer)
          Creates a public class declaration, associated to the given sourceElement.
 JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)
          Creates a public class declaration, associated to the given sourceElement.
 JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, Procedures.Procedure1<? super JvmGenericType> initializer)
          Creates a public class declaration, associated to the given sourceElement.
 JvmConstructor toConstructor(org.eclipse.emf.ecore.EObject sourceElement, Procedures.Procedure1<? super JvmConstructor> initializer)
          Creates and returns a constructor with the given simple name associated to the given source element.
 JvmEnumerationLiteral toEnumerationLiteral(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)
          Creates a public enumeration literal, associated to the given sourceElement.
 JvmEnumerationLiteral toEnumerationLiteral(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, Procedures.Procedure1<? super JvmEnumerationLiteral> initializer)
          Same as toEnumerationLiteral(EObject, String) but with an initializer passed as the last argument.
 JvmEnumerationType toEnumerationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, Procedures.Procedure1<? super JvmEnumerationType> initializer)
          Creates a public enum declaration, associated to the given sourceElement.
 JvmOperation toEqualsMethod(org.eclipse.emf.ecore.EObject sourceElement, JvmDeclaredType declaredType, boolean isDelegateToSuperEquals)
           
 JvmOperation toEqualsMethod(org.eclipse.emf.ecore.EObject sourceElement, JvmDeclaredType declaredType, boolean isDelegateToSuperEquals, JvmField... jvmFields)
           
 JvmField toField(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, JvmTypeReference typeRef)
          Creates a private field with the given name and the given type associated to the given sourceElement.
 JvmField toField(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, JvmTypeReference typeRef, Procedures.Procedure1<? super JvmField> initializer)
          Same as toField(EObject, String, JvmTypeReference) but with an initializer passed as the last argument.
 JvmOperation toGetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, JvmTypeReference typeRef)
          shorthand for toGetter(sourceElement, name, name, typeRef).
 JvmOperation toGetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String propertyName, java.lang.String fieldName, JvmTypeReference typeRef)
          Creates a getter method for the given property name and the field name.
 JvmOperation toHashCodeMethod(org.eclipse.emf.ecore.EObject sourceElement, boolean extendsSomethingWithProperHashCode, JvmDeclaredType declaredType)
           
 JvmOperation toHashCodeMethod(org.eclipse.emf.ecore.EObject sourceElement, boolean extendsSomethingWithProperHashCode, JvmField... jvmFields)
           
 JvmGenericType toInterface(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, Procedures.Procedure1<? super JvmGenericType> initializer)
          Creates a public interface declaration, associated to the given sourceElement.
 JvmOperation toMethod(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, JvmTypeReference returnType, Procedures.Procedure1<? super JvmOperation> initializer)
          Creates a public method with the given name and the given return type and associates it with the given sourceElement.
 JvmFormalParameter toParameter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, JvmTypeReference typeRef)
          Creates and returns a formal parameter for the given name and type, which is associated to the given source element.
 JvmOperation toSetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, JvmTypeReference typeRef)
          shorthand for toSetter(sourceElement, name, name, typeRef)
 JvmOperation toSetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String propertyName, java.lang.String fieldName, JvmTypeReference typeRef)
          Creates a setter method for the given properties name with the standard implementation assigning the passed parameter to a similarly named field.
 JvmOperation toToStringMethod(org.eclipse.emf.ecore.EObject sourceElement, JvmDeclaredType declaredType)
          Creates a toString() method accumulating the values of all fields.
 void translateAnnotationsTo(java.lang.Iterable<? extends XAnnotation> annotations, JvmAnnotationTarget target)
          Translates XAnnotations to JvmAnnotationReferences and adds them to the given JvmAnnotationTarget.
protected  JvmTypesBuilder.AnnotationValueTranslator translator(XExpression obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JvmTypesBuilder

public JvmTypesBuilder()
Method Detail

operator_add

public <T> boolean operator_add(@Nullable
                                org.eclipse.emf.common.util.EList<? super T> list,
                                @Nullable
                                T element)
Overrides the default operator_add() to ignore null elements.


operator_add

public <T> boolean operator_add(@Nullable
                                org.eclipse.emf.common.util.EList<? super T> list,
                                @Nullable
                                java.lang.Iterable<? extends T> elements)
Overrides the default operator_add() to ignore null elements.


setBody

public void setBody(@Nullable
                    JvmExecutable logicalContainer,
                    @Nullable
                    XExpression expr)
Sets the given JvmExecutable as the logical container for the given XExpression. This defines the context and the scope for the given expression. Also it defines how the given JvmExecutable can be executed. For instance JvmModelGenerator automatically translates any given XExpression into corresponding Java source code as the body of the given JvmExecutable.

Parameters:
logicalContainer - the JvmExecutable the expression is associated with. Can be null in which case this function does nothing.
expr - the expression. Can be null in which case this function does nothing.

removeExistingBody

protected void removeExistingBody(@Nullable
                                  JvmMember member)

initializeSafely

@Nullable
protected <T extends org.eclipse.emf.ecore.EObject> T initializeSafely(@Nullable
                                                                                T targetElement,
                                                                                @Nullable
                                                                                Procedures.Procedure1<? super T> initializer)

setBody

public void setBody(@Nullable
                    JvmExecutable executable,
                    @Nullable
                    Procedures.Procedure1<ITreeAppendable> strategy)
Attaches the given compile strategy to the given JvmExecutable such that the compiler knows how to implement the JvmExecutable when it is translated to Java source code.

Parameters:
executable - the operation or constructor to add the method body to. If null this method does nothing.
strategy - the compilation strategy. If null this method does nothing.

getDocumentation

@Nullable
public java.lang.String getDocumentation(@Nullable
                                                  org.eclipse.emf.ecore.EObject source)
Retrieves the attached documentation for the given source element. By default this implementation provides the text of a multi line comment preceding the definition of the given source element.

Returns:
the documentation of the given source, null if source is null or doesn't have any documentation.

setDocumentation

public void setDocumentation(@Nullable
                             JvmIdentifiableElement jvmElement,
                             @Nullable
                             java.lang.String documentation)
Attaches the given documentation to the given jvmElement.


toClass

@Nullable
public JvmGenericType toClass(@Nullable
                                       org.eclipse.emf.ecore.EObject sourceElement,
                                       @Nullable
                                       QualifiedName name)
Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the qualifiedName of the resulting class.
Returns:
a JvmGenericType representing a Java class of the given name, null if either parameter is null.

toClass

@Nullable
public JvmGenericType toClass(@Nullable
                                       org.eclipse.emf.ecore.EObject sourceElement,
                                       @Nullable
                                       java.lang.String name)
Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the qualifiedName of the resulting class.
Returns:
a JvmGenericType representing a Java class of the given name, null if either parameter is null.

toClass

@Nullable
public JvmGenericType toClass(@Nullable
                                       org.eclipse.emf.ecore.EObject sourceElement,
                                       @Nullable
                                       QualifiedName name,
                                       @Nullable
                                       Procedures.Procedure1<? super JvmGenericType> initializer)
Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the QualifiedName of the resulting class.
initializer - the initializer to apply on the created class element. If null, the class won't be initialized.
Returns:
a JvmGenericType representing a Java class of the given name, null if sourceElement or name are null.

toClass

@Nullable
public JvmGenericType toClass(@Nullable
                                       org.eclipse.emf.ecore.EObject sourceElement,
                                       @Nullable
                                       java.lang.String name,
                                       @Nullable
                                       Procedures.Procedure1<? super JvmGenericType> initializer)
Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the qualified name of the resulting class.
initializer - the initializer to apply on the created class element. If null, the class won't be initialized.
Returns:
a JvmGenericType representing a Java class of the given name, null if sourceElement or name are null.

toInterface

@Nullable
public JvmGenericType toInterface(@Nullable
                                           org.eclipse.emf.ecore.EObject sourceElement,
                                           @Nullable
                                           java.lang.String name,
                                           @Nullable
                                           Procedures.Procedure1<? super JvmGenericType> initializer)
Creates a public interface declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the qualified name of the resulting class.
initializer - the initializer to apply on the created interface element. If null, the interface won't be initialized.
Returns:
a JvmGenericType representing a Java class of the given name, null if sourceElement or name are null.

toAnnotationType

@Nullable
public JvmAnnotationType toAnnotationType(@Nullable
                                                   org.eclipse.emf.ecore.EObject sourceElement,
                                                   @Nullable
                                                   java.lang.String name,
                                                   @Nullable
                                                   Procedures.Procedure1<? super JvmAnnotationType> initializer)
Creates a public annotation declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the qualified name of the resulting class.
initializer - the initializer to apply on the created annotation. If null, the annotation won't be initialized.
Returns:
a JvmAnnotationType representing a Java annotation of the given name, null if sourceElement or name are null.

toEnumerationType

@Nullable
public JvmEnumerationType toEnumerationType(@Nullable
                                                     org.eclipse.emf.ecore.EObject sourceElement,
                                                     @Nullable
                                                     java.lang.String name,
                                                     @Nullable
                                                     Procedures.Procedure1<? super JvmEnumerationType> initializer)
Creates a public enum declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the qualified name of the resulting enum type.
initializer - the initializer to apply on the created enumeration type. If null, the enum won't be initialized.
Returns:
a result representing a Java enum type with the given name, null if sourceElement or name are null.

toEnumerationLiteral

@Nullable
public JvmEnumerationLiteral toEnumerationLiteral(@Nullable
                                                           org.eclipse.emf.ecore.EObject sourceElement,
                                                           @Nullable
                                                           java.lang.String name)
Creates a public enumeration literal, associated to the given sourceElement.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the simple name of the resulting enumeration literal.
Returns:
a result representing a Java enumeration literal with the given name, null if sourceElement or name are null.

toEnumerationLiteral

@Nullable
public JvmEnumerationLiteral toEnumerationLiteral(@Nullable
                                                           org.eclipse.emf.ecore.EObject sourceElement,
                                                           @Nullable
                                                           java.lang.String name,
                                                           @Nullable
                                                           Procedures.Procedure1<? super JvmEnumerationLiteral> initializer)
Same as toEnumerationLiteral(EObject, String) but with an initializer passed as the last argument.


createJvmGenericType

@Nullable
protected JvmGenericType createJvmGenericType(@Nullable
                                                       org.eclipse.emf.ecore.EObject sourceElement,
                                                       @Nullable
                                                       java.lang.String name)

splitQualifiedName

protected Pair<java.lang.String,java.lang.String> splitQualifiedName(java.lang.String name)

toField

@Nullable
public JvmField toField(@Nullable
                                 org.eclipse.emf.ecore.EObject sourceElement,
                                 @Nullable
                                 java.lang.String name,
                                 @Nullable
                                 JvmTypeReference typeRef)
Creates a private field with the given name and the given type associated to the given sourceElement.

Parameters:
sourceElement - the sourceElement the resulting element is associated with.
name - the simple name of the resulting field.
typeRef - the type of the field
Returns:
a JvmField representing a Java field with the given simple name and type.

toField

@Nullable
public JvmField toField(@Nullable
                                 org.eclipse.emf.ecore.EObject sourceElement,
                                 @Nullable
                                 java.lang.String name,
                                 @Nullable
                                 JvmTypeReference typeRef,
                                 @Nullable
                                 Procedures.Procedure1<? super JvmField> initializer)
Same as toField(EObject, String, JvmTypeReference) but with an initializer passed as the last argument.


associate

@Nullable
public <T extends JvmIdentifiableElement> T associate(@Nullable
                                                               org.eclipse.emf.ecore.EObject sourceElement,
                                                               @Nullable
                                                               T target)
Associates a source element with a target element. This association is used for tracing. Navigation, for instance, uses this information to find the real declaration of a Jvm element.

Returns:
the target for convenience.
See Also:
IJvmModelAssociator, IJvmModelAssociations

toMethod

@Nullable
public JvmOperation toMethod(@Nullable
                                      org.eclipse.emf.ecore.EObject sourceElement,
                                      @Nullable
                                      java.lang.String name,
                                      @Nullable
                                      JvmTypeReference returnType,
                                      @Nullable
                                      Procedures.Procedure1<? super JvmOperation> initializer)
Creates a public method with the given name and the given return type and associates it with the given sourceElement.

Parameters:
sourceElement - the sourceElement the method should be associated with.
name - the simple name of the method to be created.
returnType - the return type of the created method.
initializer - the initializer to apply on the created method. If null, the method won't be initialized.
Returns:
a result representing a Java method with the given name, null if sourceElement or name are null.

toGetter

@Nullable
public JvmOperation toGetter(@Nullable
                                      org.eclipse.emf.ecore.EObject sourceElement,
                                      @Nullable
                                      java.lang.String name,
                                      @Nullable
                                      JvmTypeReference typeRef)
shorthand for toGetter(sourceElement, name, name, typeRef).


toGetter

@Nullable
public JvmOperation toGetter(@Nullable
                                      org.eclipse.emf.ecore.EObject sourceElement,
                                      @Nullable
                                      java.lang.String propertyName,
                                      @Nullable
                                      java.lang.String fieldName,
                                      @Nullable
                                      JvmTypeReference typeRef)
Creates a getter method for the given property name and the field name. Example: public String getPropertyName() { return this.fieldName; }

Returns:
a getter method for a JavaBeans property, null if sourceElement or name are null.

toSetter

@Nullable
public JvmOperation toSetter(@Nullable
                                      org.eclipse.emf.ecore.EObject sourceElement,
                                      @Nullable
                                      java.lang.String name,
                                      @Nullable
                                      JvmTypeReference typeRef)
shorthand for toSetter(sourceElement, name, name, typeRef)


toSetter

@Nullable
public JvmOperation toSetter(@Nullable
                                      org.eclipse.emf.ecore.EObject sourceElement,
                                      @Nullable
                                      java.lang.String propertyName,
                                      @Nullable
                                      java.lang.String fieldName,
                                      @Nullable
                                      JvmTypeReference typeRef)
Creates a setter method for the given properties name with the standard implementation assigning the passed parameter to a similarly named field. Example: public void setFoo(String foo) { this.foo = foo; }

Returns:
a setter method for a JavaBeans property with the given name, null if sourceElement or name are null.

toParameter

@Nullable
public JvmFormalParameter toParameter(@Nullable
                                               org.eclipse.emf.ecore.EObject sourceElement,
                                               @Nullable
                                               java.lang.String name,
                                               @Nullable
                                               JvmTypeReference typeRef)
Creates and returns a formal parameter for the given name and type, which is associated to the given source element.

Returns:
a Java parameter given name, null if sourceElement or name are null.

toConstructor

@Nullable
public JvmConstructor toConstructor(@Nullable
                                             org.eclipse.emf.ecore.EObject sourceElement,
                                             @Nullable
                                             Procedures.Procedure1<? super JvmConstructor> initializer)
Creates and returns a constructor with the given simple name associated to the given source element. By default the constructor will have an empty body and no arguments, hence the Java default constructor.

Parameters:
sourceElement - the sourceElement the constructor should be associated with.
initializer - the initializer to apply on the created constructor. If null, the method won't be initialized.
Returns:
a result representing a Java constructor with the given name, null if sourceElement is null.

toToStringMethod

@Nullable
public JvmOperation toToStringMethod(@Nullable
                                              org.eclipse.emf.ecore.EObject sourceElement,
                                              @Nullable
                                              JvmDeclaredType declaredType)
Creates a toString() method accumulating the values of all fields.

Returns:
a result representing a Java toString() method, null if sourceElement or declaredType are null.

toHashCodeMethod

@Nullable
public JvmOperation toHashCodeMethod(@Nullable
                                              org.eclipse.emf.ecore.EObject sourceElement,
                                              boolean extendsSomethingWithProperHashCode,
                                              @Nullable
                                              JvmDeclaredType declaredType)

toHashCodeMethod

@Nullable
public JvmOperation toHashCodeMethod(@Nullable
                                              org.eclipse.emf.ecore.EObject sourceElement,
                                              boolean extendsSomethingWithProperHashCode,
                                              JvmField... jvmFields)

toEqualsMethod

@Nullable
public JvmOperation toEqualsMethod(@Nullable
                                            org.eclipse.emf.ecore.EObject sourceElement,
                                            @Nullable
                                            JvmDeclaredType declaredType,
                                            boolean isDelegateToSuperEquals)

toEqualsMethod

@Nullable
public JvmOperation toEqualsMethod(@Nullable
                                            org.eclipse.emf.ecore.EObject sourceElement,
                                            @Nullable
                                            JvmDeclaredType declaredType,
                                            boolean isDelegateToSuperEquals,
                                            JvmField... jvmFields)

toAnnotation

@Nullable
public JvmAnnotationReference toAnnotation(@Nullable
                                                    org.eclipse.emf.ecore.EObject sourceElement,
                                                    @Nullable
                                                    java.lang.Class<?> annotationType)
Creates and returns an annotation reference of the given annotation type.

See Also:
toAnnotation(EObject, Class, Object)

toAnnotation

@Nullable
public JvmAnnotationReference toAnnotation(@Nullable
                                                    org.eclipse.emf.ecore.EObject sourceElement,
                                                    @Nullable
                                                    java.lang.String annotationTypeName)
Creates and returns an annotation reference of the given annotation type's name.

See Also:
toAnnotation(EObject, String, Object)

toAnnotation

@Nullable
public JvmAnnotationReference toAnnotation(@Nullable
                                                    org.eclipse.emf.ecore.EObject sourceElement,
                                                    @Nullable
                                                    java.lang.Class<?> annotationType,
                                                    @Nullable
                                                    java.lang.Object value)
Creates and returns an annotation reference of the given annotation type's name and the given value.

Parameters:
sourceElement - the source element to associate the created element with.
annotationType - the type of the created annotation reference.
value - the value of the annotation reference. Can be null if the reference doesn't have any value.
Returns:
a result representing an annotation reference to the given annotation type, null if sourceElement or annotationType are null.

toAnnotation

@Nullable
public JvmAnnotationReference toAnnotation(@Nullable
                                                    org.eclipse.emf.ecore.EObject sourceElement,
                                                    @Nullable
                                                    java.lang.String annotationTypeName,
                                                    @Nullable
                                                    java.lang.Object value)
Creates and returns an annotation reference of the given annotation type's name and the given value.

Parameters:
sourceElement - the source element to associate the created element with.
annotationTypeName - the type name of the created annotation.
value - the value of the annotation reference. Can be null if the reference doesn't have any value.
Returns:
a result representing an annotation reference to the given annotation type, null if sourceElement or annotationType are null.

cloneWithProxies

@Nullable
public JvmTypeReference cloneWithProxies(@Nullable
                                                  JvmTypeReference typeRef)
Creates a clone of the given JvmTypeReference without resolving any proxies. The clone will be associated with the original element by means of associations.

Parameters:
typeRef - the type reference to be cloned.
Returns:
a clone of typeRef, null if typeRef is null or a JvmUnknownTypeReference if there is a problem with the typeRef.

cloneWithProxies

@Nullable
public <T extends JvmIdentifiableElement> T cloneWithProxies(@Nullable
                                                                      T original)
Creates a clone of the given JvmIdentifiableElement without resolving any proxies. The clone will be associated with the original element by means of associations.

Parameters:
original - the element to be cloned.
Returns:
a clone of original associated with the original, null if original is null.

cloneAndAssociate

protected <T extends org.eclipse.emf.ecore.EObject> T cloneAndAssociate(T original)
Creates a deep copy of the given object and associates each copied instance with the clone. Does not resolve any proxies.

Parameters:
original - the root element to be cloned.
Returns:
a clone of tree rooted in original associated with the original, null if original is null.

cloneAndAssociate

protected <T extends JvmTypeReference> T cloneAndAssociate(T original)
Creates a deep copy of the given object and associates each copied instance with the clone. Does not resolve any proxies.

Parameters:
original - the root element to be cloned.
Returns:
a clone of tree rooted in original associated with the original, null if original is null.

setInitializer

public void setInitializer(@Nullable
                           JvmField field,
                           @Nullable
                           Procedures.Procedure1<ITreeAppendable> strategy)
Attaches the given compile strategy to the given JvmField such that the compiler knows how to initialize the JvmField when it is translated to Java source code.

Parameters:
field - the field to add the initializer to. If null this method does nothing.
strategy - the compilation strategy. If null this method does nothing.

setInitializer

public void setInitializer(@Nullable
                           JvmField field,
                           @Nullable
                           XExpression expr)
Sets the given JvmField as the logical container for the given XExpression. This defines the context and the scope for the given expression.

Parameters:
field - the JvmField that is initialized by the expression. If null this method does nothing.
expr - the initialization expression. Can be null in which case this function does nothing.

setCompilationStrategy

protected void setCompilationStrategy(@Nullable
                                      JvmMember member,
                                      @Nullable
                                      Procedures.Procedure1<ITreeAppendable> strategy)

newTypeRef

@Nullable
public JvmTypeReference newTypeRef(@Nullable
                                            org.eclipse.emf.ecore.EObject ctx,
                                            @Nullable
                                            java.lang.Class<?> clazz,
                                            @Nullable
                                            JvmTypeReference... typeArgs)
Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.

Parameters:
ctx - an EMF context, which is used to look up the JvmType for the given clazz.
clazz - the class the type reference shall point to.
typeArgs - type arguments
Returns:
the newly created JvmTypeReference

newTypeRef

@Nullable
public JvmTypeReference newTypeRef(@Nullable
                                            org.eclipse.emf.ecore.EObject ctx,
                                            @Nullable
                                            java.lang.String typeName,
                                            @Nullable
                                            JvmTypeReference... typeArgs)
Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.

Parameters:
ctx - an EMF context, which is used to look up the JvmType for the given clazz.
typeName - the name of the type the reference shall point to.
typeArgs - type arguments
Returns:
the newly created JvmTypeReference

newTypeRef

@Nullable
public JvmTypeReference newTypeRef(@Nullable
                                            JvmDeclaredType type,
                                            @Nullable
                                            JvmTypeReference... typeArgs)
Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.

Parameters:
type - the type the reference shall point to.
typeArgs - type arguments
Returns:
the newly created JvmTypeReference

addArrayTypeDimension

@Nullable
public JvmTypeReference addArrayTypeDimension(@Nullable
                                                       JvmTypeReference componentType)
Returns:
an array type of the given type reference. Add one dimension if the given JvmTypeReference is already an array.

translateAnnotationsTo

public void translateAnnotationsTo(@Nullable
                                   java.lang.Iterable<? extends XAnnotation> annotations,
                                   @Nullable
                                   JvmAnnotationTarget target)
Translates XAnnotations to JvmAnnotationReferences and adds them to the given JvmAnnotationTarget.

Parameters:
target - the annotation target. If null this method does nothing.
annotations - the annotations. If null this method does nothing.

getJvmAnnotationReference

@Nullable
public JvmAnnotationReference getJvmAnnotationReference(@Nullable
                                                                 XAnnotation anno)

getJvmAnnotationValue

@Nullable
protected JvmAnnotationValue getJvmAnnotationValue(@Nullable
                                                            XExpression value)

translator

@Nullable
protected JvmTypesBuilder.AnnotationValueTranslator translator(@Nullable
                                                                        XExpression obj)