functions.SoftLink.ext Maven / Gradle / Ivy
extension java::GeneratorCommons;
extension functions::SystemProperties;
cached boolean isSoftLink(uml::Element element):
element.isStereotypeApplied("SoftLink");
cached JMM::SoftLink asSoftLink(uml::Element element):
(JMM::SoftLink) element;
cached String getJavaSoftLinkType(JMM::SoftLink softLink):
if (softLink.softLinkType.name == "CustomGenericType")
then getJavaGenericSoftLinkType()
else softLink.softLinkType.name;
cached String getMultivaluedJavaSoftLinkType(JMM::SoftLink softLink):
if (softLink.softLinkType.name == "CustomGenericType")
then getJavaGenericSoftLinkType()
else softLink.softLinkType.name.toFirstUpper();
cached String getJavaGenericSoftLinkType():
getSystemProperty("switch.gen.java.generic.soft.link.type");
cached String getOpenAPIGenericSoftLinkType():
getSystemProperty("switch.gen.openapi.generic.soft.link.type", "string");
private cached String getSoftLinkSuffix():
getSystemProperty("switch.gen.openapi.generic.soft.link.suffix", "");
cached boolean useSoftLinkSuffixInOpenAPI():
getBooleanSystemProperty("switch.gen.openapi.generic.soft.link.suffix.use", true);
cached boolean hasSoftLinkSuffix(uml::Property property):
getSoftLinkSuffix().length > 0;
cached String getSoftLinkPropertyName(uml::Property property):
if property.isMultivalued()
then getSoftLinkPropertyName(property.name, getSoftLinkSuffix())
else property.name + getSoftLinkSuffix();
cached String getSoftLinkPropertyName(String propertyName, String suffix):
if propertyName.endsWith("ies")
then propertyName.subString(0, propertyName.length-3) + "y" + suffix + "s"
else
if propertyName.endsWith("s")
then propertyName.subString(0, propertyName.length-1) + suffix + "s"
else propertyName + suffix;
cached String getSoftLinkAwarePropertyNameForJava(uml::Property property):
if property.isSoftLink()
then property.getSoftLinkPropertyName()
else property.name;
cached String getSoftLinkAwarePropertyNameForOpenAPI(uml::Property property):
if property.isSoftLink() && useSoftLinkSuffixInOpenAPI()
then property.getSoftLinkPropertyName()
else property.name;