java.Naming.ext Maven / Gradle / Ivy
extension java::GeneratorCommons;
extension java::OpenAPIFunctions;
extension functions::JEAFDeprecated;
extension functions::BreakingChange;
extension functions::Class;
extension functions::TemplateParameter;
extension functions::Operation;
extension functions::Alias;
extension functions::DefaultComment;
extension functions::Parameter;
// Function returns the name of the parameter for a java method accoring to the anaptecs code styleguide. For the
// element "name" the function will return "pName".
cached String asParameter (uml::NamedElement element) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.asParameterName( org.eclipse.uml2.uml.NamedElement );
cached String asParameter (String name) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.asParameterName( java.lang.String );
// Function returns the name of the java set method for this named element. For the element "name" the function will
// return "setName".
String asSetter (uml::NamedElement element) :
"set" + element.name.toFirstUpper();
// Function returns the name of the java get method for this named element. For the element "name" the function will
// return "getName".
String asGetter (uml::NamedElement element) :
"get" + element.name.toFirstUpper();
// Function returns the name of the java unset method for this named element. For the element "name" the function will
// return "unsetName".
String asUnset (uml::NamedElement element) :
"unset" + element.name.toFirstUpper();
cached String asInstanceVar (uml::NamedElement elem) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.asInstanceName( org.eclipse.uml2.uml.NamedElement );
cached String asLocalVar (uml::NamedElement elem) :
"l" + elem.name.toFirstUpper();
String asIdField (uml::NamedElement elem) :
elem.asField()+"_OID";
String getForeignKeyName (uml::NamedElement elem) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getForeignKeyName(org.eclipse.uml2.uml.NamedElement );
String asField (uml::NamedElement elem) :
elem.name.toUpperCase();
// Liefert den Package-Namen einer Klasse
String packageName (uml::NamedElement cls) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getPackageName(org.eclipse.uml2.uml.NamedElement);
// Liefert das Package einer Klasse als Pfad
String packagePath (uml::NamedElement cls) :
packageName(cls).replaceAll("\\.", "/");
String packagePath (uml::Package package) :
packageName(package).replaceAll("\\.", "/");
// Liefert das Package einer Klasse als Pfad
String packagePath (String path) :
path.replaceAll("\\.", "/");
// Function returns the name of the business object base class for the passed class. The functions result will be cached
// since it will be called for the same object many times during the generation process.
cached String getBOBaseName (uml::Class cls) :
cls.name + "Base";
// Function returns the name of the business object class for the passed class. The functions result will be cached
// since it will be called for the same object many times during the generation process.
cached String getBOName (uml::Type type) :
type.name;
// Method returns the name for the JEAF Command class or the passed method object. The returned name will be created
// from the name of the method and the type of each parameter.
cached String getCommandClassName(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.getCommandClassName( org.eclipse.uml2.uml.Operation);
// Function returns the name of the service object mapper for the paased class.
cached String getObjectMapperName(uml::Type type) :
type.name + "Converter";
// Function returns the name of the service object mapper for the paased class.
cached String getObjectMapperName(String sourceName, String targetName) :
sourceName+ "To" + targetName + "Converter";
// Function returns the name of the service provider factory for the passed class.
cached String getServiceProviderFactoryName(uml::Class class) :
class.name + "Factory";
// Function returns the name of the test case base class.
cached String getTestCaseBaseName(uml::NamedElement element) :
element.name + "TestBase";
// Function returns the name of the test case class.
cached String getTestCaseName(uml::NamedElement element) :
element.name + "Test";
cached String javaFQN(uml::NamedElement element):
element.fqn();
cached String umlFQN(uml::NamedElement element):
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.getUMLQualifiedName( org.eclipse.uml2.uml.NamedElement);
// For "normale" Typen wird einfach der Name als qualifizierter Name geliefert
// Blob wird von OAW nicht als Klasse anerkannt, deswegen muss sie hier behandelt werden.
cached String fqn(uml::NamedElement element) :
if element.isClass()
then element.asClass().internalFQNForClass()
else element.internalFQN();
cached String fqnWithoutGenerics(uml::NamedElement element):
element.internalFQN(true);
private cached String internalFQNForClass(uml::Class class):
if class.templateBinding.isEmpty
then class.internalFQN() + class.getTemplateParams()
else class.fqnForTemplateClass();
cached String getTemplateParams(uml::Class class):
if class.hasTemplateParameter()
then "<" + class.ownedTemplateSignature.ownedParameter.getTemplateParameterName().toString(", ") + ">"
else "";
private cached String fqnForTemplateClass(uml::Class class):
class.getGenericTypeForTemplate() + "<" + class.getTypeParameterName() + ">";
cached String getTypeParameterName(uml::Class class):
class.templateBinding.first().parameterSubstitution.first().actual.first().asClass().fqn();
private cached String getGenericTypeForTemplate(uml::Class class):
class.getGenericClass().package.fqn() + "." + class.getGenericClass().name;
cached uml::Class getGenericClass(uml::Class class):
class.templateBinding.first().target.first().owner.asClass();
// «IF hasTemplateParameter()»<«FOREACH ownedTemplateSignature.ownedParameter AS param SEPARATOR ", "»«param.getTemplateParameterName()» «IF param.hasTemplateParameterBaseType()» extends «param.getTemplateParameterBaseType()»«ENDIF»«ENDFOREACH»>«ENDIF»
private cached String internalFQN(uml::NamedElement element) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.getFullyQualifiedName( org.eclipse.uml2.uml.NamedElement);
private cached String internalFQN(uml::NamedElement element, boolean igonreTemplateBinding) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.getFullyQualifiedName(org.eclipse.uml2.uml.NamedElement, java.lang.Boolean);
// For "normale" Typen wird einfach der Name als qualifizierter Name geliefert
// Blob wird von OAW nicht als Klasse anerkannt, deswegen muss sie hier behandelt werden.
cached String fqnForXML (uml::NamedElement element) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.getFullyQualifiedNameForXML( org.eclipse.uml2.uml.NamedElement);
// *** HILFSFUNKTIONEN ***
// mit private gekennzeichnete Extensions sind nicht ausserhalb des Extension Files sichtbar
// Diese Funktion ermittelt rekursiv den qualifizierten Packagenamen eines Packages.
private cached String packageName (uml::Package pck) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getPackageName(org.eclipse.uml2.uml.Package);
String getComment(uml::Element element):
if element.ownedComment.isEmpty == false
then element.ownedComment.first().body.trim()
else "";
//String getComment(List commentList):
// commentList.size > 0 ? getComment(commentList.get(0)) : "";
//String getComment(uml::Comment comment):
// comment.body.trim();
boolean hasComment(uml::Element element):
element.getComment().length > 0 || (element.isParameter() && element.hasDefaultComment()) || (element.isOperation() && element.asOperation().hasSecurityRoles()) || (element.isJEAFDeprecated() && ((uml::NamedElement) element).hasMeaningfulDeprecationInfo()) || element.hasAliasAttributeName() || element.isBreakingChange() || element.isAlias();
//String getComment(Object this): "";
// Konvertiert einen Parameter zu einer Instanzvariable
String fromParameterToInstance(uml::NamedElement elem) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.fromParameterToInstance(org.eclipse.uml2.uml.NamedElement);
// Returns the parameter names as list, comma separated
cached String asParameterListNames(uml::Operation operation) :
operation.getInputParameters().select(e|e.isParameterSuppressed() == false).name.toString(", ");
cached String getParameterTypeNames(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getParameterTypeNames(org.eclipse.uml2.uml.Operation);
// Returns the parameters as Java Doc for a operation
String asParameterJavaDoc(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getParameterJavaDoc(org.eclipse.uml2.uml.Operation);
// Returns the paramters names as list, coma separated, cuts off the first letter (should always be "p")
String asParameterListInstanceNames(uml::Operation operation) :
operation.getInputParameters().select(e|e.isParameterSuppressed() == false).fromParameterToInstance().toString(", ");
String asParameterDefinitionList(List parameters):
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.asParameterDefinitionList(java.util.List);
cached boolean isInputParameter(uml::Parameter parameter):
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.isInputParameter(org.eclipse.uml2.uml.Parameter);
cached List[uml::Parameter] getInputParameters(uml::Operation operation):
operation.ownedParameter.select(p| p.isInputParameter());
cached boolean areAllInputParametersNamed(uml::Operation operation):
operation.getInputParameters().select(e|e.name.length == 0).isEmpty;
boolean hasInputParameters(uml::Operation operation):
getInputParameters(operation).size > 0;
// Returns the name of the parameter's type, adds a "[]" at the end if the parameter is multivalued
cached String getTypeName(uml::TypedElement parameter) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getTypeName(org.eclipse.uml2.uml.TypedElement);
// Returns the name of the return parameter, adds a "[]" at the end if the parameter is multivalued
cached String getReturnTypeName(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getReturnType(org.eclipse.uml2.uml.Operation);
cached boolean returnsPrimitiveType(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.returnsPrimitiveType(org.eclipse.uml2.uml.Operation);
cached boolean isReturnTypeVoid(uml::Operation operation):
operation.getReturnTypeName() == "void";
cached boolean isSupportedReturnType(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.isSupportedReturnType(org.eclipse.uml2.uml.Operation);
boolean hasReturnType(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.hasReturnType(org.eclipse.uml2.uml.Operation);
cached uml::Parameter getReturnType(uml::Operation operation):
operation.returnResult().first();
boolean hasOnlySupportedParamaterTypes(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.hasOnlySupportedParamaterTypes(org.eclipse.uml2.uml.Operation);
boolean isPrimitiveType(uml::Type type) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.isPrimitive(org.eclipse.uml2.uml.Type);
String getPrimitiveDefaultValue(uml::Property type):
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getPrimitiveDefaultValue(org.eclipse.uml2.uml.Property);
boolean isBasicType(uml::Type type):
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.isBasicType(org.eclipse.uml2.uml.Type);
// Returns the thrown Exceptions of a method, exceptions come separated by a ","
String getThrownExceptionsAsString(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getThrownExceptionsAsString(org.eclipse.uml2.uml.Operation);
// Returns the thrown Exceptions of a method, exceptions come separated by a ","
List getThrownExceptionsAsList(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getThrownExceptionsAsList(org.eclipse.uml2.uml.Operation);
// Verifies whether this operation throws a ApplicationException or a subclass of it.
boolean throwsApplicationException(uml::Operation operation) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.throwsApplicationException(org.eclipse.uml2.uml.Operation);
// Returns the name of the subclass of the Exception which this operation raises.
// Supported are ApplicationException and SystemException.
String getExceptionName(uml::Operation operation, String type) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getExceptionName(org.eclipse.uml2.uml.Operation, java.lang.String);
// Returns the number of the contained JEAF services.
int countJeafServices(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.countJeafServices(org.eclipse.uml2.uml.Component);
// Returns the Jeaf services. The result is a list with uml::Interface objects.
List getJeafServices(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getJeafServices(org.eclipse.uml2.uml.Component);
// Returns the Jeaf services. The result is a list with uml::Interface objects.
List getJEAFServices(uml::Port port) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getJEAFServices(org.eclipse.uml2.uml.Port);
// Returns the Jeaf services. The result is a list with uml::Interface objects.
List getAllProvidedJEAFServices(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getAllProvidedJEAFServices(org.eclipse.uml2.uml.Component);
cached JMM::PersistenceUnit getPersistenceUnit(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getPersistenceUnit(org.eclipse.uml2.uml.Component);
boolean hasPersistenceUnit(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.hasPersistenceUnit(org.eclipse.uml2.uml.Component);
// Returns the Jeaf services. The result is a list with uml::Interface objects.
List getInterceptors(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getInterceptors(org.eclipse.uml2.uml.Component);
String getImplementedInterfaceNames(uml::Class class) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getImplementedInterfaces(org.eclipse.uml2.uml.Class);
List getRequiredServicesSorted(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getRequiredServicesSorted(org.eclipse.uml2.uml.Component);
List getRequiredServicesSorted(uml::Port port) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getRequiredServicesSorted(org.eclipse.uml2.uml.Port);
List getAllRequiredJEAFServices(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getAllRequiredJEAFServices(org.eclipse.uml2.uml.Component);
// Checks class ids of all entities and service entities. Ensures that no class id is used twice in two direfent
// classes. Returns a list with all used class ids with their class names.
List getClassIDs(uml::Package package) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getClassIDs(org.eclipse.uml2.uml.Package);
// Checks property if its tagged value tabel is valid
Boolean isTableValid(uml::Property property) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.isTableValid(org.eclipse.uml2.uml.Property);
// Gets the link table of this many to many association
String getLinkTable(uml::Property property) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getLinkTable(org.eclipse.uml2.uml.Property);
uml::Class getOppositeEndType(uml::Property role) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getOppositeEndType(org.eclipse.uml2.uml.Property);
// Function returns the name of the passed cascade type. The name of the cascade type will be converted to lower case
// characters.
cached String getCascadeTypeNames(Collection cascadeTypes) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getEnumerationLiteralsAsString(java.util.Collection);
boolean isRealInitValue(uml::Property property) :
JAVA com.anaptecs.jeaf.fwk.generator.util.GeneratorCommons.isRealInitValue(org.eclipse.uml2.uml.Property);
cached boolean isPersistentObject(uml::NamedElement namedElement) :
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.isPersistentObject(org.eclipse.uml2.uml.NamedElement);
cached String getCollectionType(uml::MultiplicityElement multiplicityElement) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getCollectionType(org.eclipse.uml2.uml.MultiplicityElement);
cached String getCollectionTypeShort(uml::MultiplicityElement multiplicityElement) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getCollectionTypeShort(org.eclipse.uml2.uml.MultiplicityElement);
cached boolean isCollectionType(uml::Property propery) :
(propery.isMultivalued() && propery.association != null) || (propery.isMultivalued() && useArraysOnlyForPrimitives() && propery.type.isPrimitiveType() == false);
cached String getEmptyCollectionOperation(uml::MultiplicityElement multiplicityElement) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getEmptyCollectionOperation(org.eclipse.uml2.uml.MultiplicityElement);
cached String getCollectionImplType(uml::MultiplicityElement multiplicityElement) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getCollectionImplType(org.eclipse.uml2.uml.MultiplicityElement);
cached String getAllExtendedInterfaces(uml::Interface interface) :
JAVA com.anaptecs.jeaf.fwk.generator.util.GeneratorCommons.getAllExtendedInterfaces(org.eclipse.uml2.uml.Interface);
cached List getAllRealProperties(uml::Component component) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.getAllRealProperties(org.eclipse.uml2.uml.Component);
cached Set getOperationNames(uml::Interface interface):
JAVA com.anaptecs.jeaf.fwk.generator.util.Naming.getOperationNames(org.eclipse.uml2.uml.Interface);
cached boolean hasMultivaluedAssociation(uml::Class class) :
JAVA com.anaptecs.jeaf.fwk.generator.util.ClassUtil.hasMultivaluedAssociation(org.eclipse.uml2.uml.Class);
cached boolean isValidationStereotype(uml::Stereotype stereotype) : !stereotype.allParents().select(e|e.name == "Validation").isEmpty;
cached boolean hasValidationStereotype(uml::NamedElement element) :
element.getAppliedStereotypes().selectFirst(e|e.isValidationStereotype()) != null;
cached boolean requiresNotNullAnnotation(uml::NamedElement element) :
if element.isStereotypeApplied("NotEmpty") || element.isStereotypeApplied("NotBlank") || element.isStereotypeApplied("Null") || element.isStereotypeApplied("NotNull")
then false
else true;
cached boolean hasErrorCodeOrSeverity(JMM::Validation validation):
validation.errorCode > 0 || validation.severity.name != "NotUsed";
cached boolean requiresInitValue(uml::Property property):
(property.isReadOnly() == true && property.isStatic == false) || (property.isRealInitValue() == true && property.isStatic == false);
cached boolean requiresAttributeInitValue(uml::Class class):
!class.ownedAttribute.select(p|p.requiresInitValue()).isEmpty;
cached boolean isValidIdentifierName(uml::NamedElement namedElement):
if namedElement.name == null
then false
else namedElement.name.isValidIdentifierNameAsString();
cached boolean isValidIdentifierNameAsString(String name):
name.matches("^([a-zA-Z_$][a-zA-Z\\d_$]*)$");