Skip to content

Commit 7e324c1

Browse files
committed
Update functionality
1 parent 78d3da0 commit 7e324c1

File tree

9 files changed

+30
-31
lines changed

9 files changed

+30
-31
lines changed

core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/AspectModelJavaUtil.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.eclipse.esmf.aspectmodel.java.exception.CodeGenerationException;
3030
import org.eclipse.esmf.aspectmodel.visitor.AspectStreamTraversalVisitor;
3131
import org.eclipse.esmf.metamodel.AbstractEntity;
32-
import org.eclipse.esmf.metamodel.Aspect;
3332
import org.eclipse.esmf.metamodel.Characteristic;
3433
import org.eclipse.esmf.metamodel.ComplexType;
3534
import org.eclipse.esmf.metamodel.Entity;
@@ -354,7 +353,7 @@ public static String toConstant( final String upperOrLowerCamel ) {
354353
}
355354
return TO_CONSTANT.convert( StringUtils.capitalize( upperOrLowerCamel ) );
356355
}
357-
356+
358357
public static boolean isAllUppercaseWithUnderscore( final String upperOrLowerCamel ) {
359358
return upperOrLowerCamel != null && upperOrLowerCamel.matches( "[A-Z0-9_]+" );
360359
}
@@ -561,8 +560,8 @@ public static String genericClassSignature( final StructureElement element ) {
561560
}
562561

563562
public static String generateClassName( final StructureElement element, final JavaCodeGenerationConfig config ) {
564-
if ( ( !config.aspectPrefix().isBlank() || !config.aspectPostfix().isBlank() ) && element instanceof Aspect ) {
565-
return config.aspectPrefix() + element.getName() + config.aspectPostfix();
563+
if ( ( !config.namePrefix().isBlank() || !config.namePostfix().isBlank() ) && element.is( StructureElement.class ) ) {
564+
return config.namePrefix() + element.getName() + config.namePostfix();
566565
}
567566
return element.getName();
568567
}

core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/JavaCodeGenerationConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public record JavaCodeGenerationConfig(
3030
ImportTracker importTracker,
3131
boolean executeLibraryMacros,
3232
File templateLibFile,
33-
String aspectPrefix,
34-
String aspectPostfix
33+
String namePrefix,
34+
String namePostfix
3535

3636
) implements GenerationConfig {
3737
public JavaCodeGenerationConfig {
@@ -47,11 +47,11 @@ public record JavaCodeGenerationConfig(
4747
if ( executeLibraryMacros && !templateLibFile.exists() ) {
4848
throw new CodeGenerationException( "Incorrect configuration. Please provide a valid path to the velocity template library file." );
4949
}
50-
if ( aspectPrefix == null ) {
51-
aspectPrefix = "";
50+
if ( namePrefix == null ) {
51+
namePrefix = "";
5252
}
53-
if ( aspectPostfix == null ) {
54-
aspectPostfix = "";
53+
if ( namePostfix == null ) {
54+
namePostfix = "";
5555
}
5656
}
5757
}

core/esmf-aspect-model-java-generator/src/test/java/org/eclipse/esmf/aspectmodel/java/AspectModelJavaGeneratorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ private Collection<JavaGenerator> getGenerators( final AspectModel aspectModel )
9999
return List.of( new AspectModelJavaGenerator( aspectModel.aspect(), config ) );
100100
}
101101

102-
private Collection<JavaGenerator> getGenerators( final TestAspect testAspect, final String aspectPrefix, final String aspectPostfix ) {
102+
private Collection<JavaGenerator> getGenerators( final TestAspect testAspect, final String namePrefix, final String namePostfix ) {
103103
final AspectModel aspectModel = TestResources.load( testAspect );
104104
final JavaCodeGenerationConfig config = JavaCodeGenerationConfigBuilder.builder()
105105
.enableJacksonAnnotations( true )
106106
.executeLibraryMacros( false )
107107
.packageName( aspectModel.aspect().urn().getNamespaceMainPart() )
108-
.aspectPrefix( aspectPrefix )
109-
.aspectPostfix( aspectPostfix )
108+
.namePrefix( namePrefix )
109+
.namePostfix( namePostfix )
110110
.build();
111111
return List.of( new AspectModelJavaGenerator( aspectModel.aspect(), config ) );
112112
}

core/esmf-aspect-model-java-generator/src/test/java/org/eclipse/esmf/aspectmodel/java/JavaCodeGenerationConfigurationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public void testValidTemplateLibConfig() {
3636
.packageName( "" )
3737
.executeLibraryMacros( true )
3838
.templateLibFile( templateLibFile )
39-
.aspectPrefix( "" )
40-
.aspectPostfix( "" )
39+
.namePrefix( "" )
40+
.namePostfix( "" )
4141
.build()
4242
).doesNotThrowAnyException();
4343

@@ -47,8 +47,8 @@ public void testValidTemplateLibConfig() {
4747
.packageName( "" )
4848
.executeLibraryMacros( false )
4949
.templateLibFile( emptyTemplateLibFile )
50-
.aspectPrefix( "" )
51-
.aspectPostfix( "" )
50+
.namePrefix( "" )
51+
.namePostfix( "" )
5252
.build()
5353
).doesNotThrowAnyException();
5454
}

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/CodeGenerationMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public abstract class CodeGenerationMojo extends AspectModelMojo {
3939
protected String stripNamespace = "";
4040

4141
@Parameter
42-
protected String aspectPrefix = "";
42+
protected String namePrefix = "";
4343

4444
@Parameter
45-
protected String aspectPostfix = "";
45+
protected String namePostfix = "";
4646

4747
protected void validateParameters( final File templateLibFile ) throws MojoExecutionException {
4848
if ( executeLibraryMacros && !templateLibFile.exists() ) {

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateJavaClasses.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public void executeGeneration() throws MojoExecutionException {
4747
.packageName( determinePackageName( aspect ) )
4848
.executeLibraryMacros( executeLibraryMacros )
4949
.templateLibFile( templateLibFile )
50-
.aspectPrefix( aspectPrefix )
51-
.aspectPostfix( aspectPostfix )
50+
.namePrefix( namePrefix )
51+
.namePostfix( namePostfix )
5252
.build();
5353
new AspectModelJavaGenerator( aspect, config ).generate( nameMapper );
5454
}

tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateStaticJavaClasses.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public void executeGeneration() throws MojoExecutionException {
4242
.packageName( determinePackageName( aspect ) )
4343
.executeLibraryMacros( executeLibraryMacros )
4444
.templateLibFile( templateLibFile )
45-
.aspectPrefix( aspectPrefix )
46-
.aspectPostfix( aspectPostfix )
45+
.namePrefix( namePrefix )
46+
.namePostfix( namePostfix )
4747
.build();
4848
new StaticMetaModelJavaGenerator( aspect, config ).generate( nameMapper );
4949
}

tools/esmf-aspect-model-maven-plugin/src/test/resources/generate-java-classes-pom-with-prefix-and-postfix.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
</includes>
3434
<outputDirectory>${basedir}/target/test-artifacts</outputDirectory>
3535
<packageName>example.com</packageName>
36-
<aspectPrefix>Base</aspectPrefix>
37-
<aspectPostfix>Postfix</aspectPostfix>
36+
<namePrefix>Base</namePrefix>
37+
<namePostfix>Postfix</namePostfix>
3838
</configuration>
3939
</plugin>
4040
</plugins>

tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/to/AspectToJavaCommand.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public class AspectToJavaCommand extends AbstractCommand {
6060
@CommandLine.Option( names = { "--static", "-s" }, description = "Generate Java domain classes for a Static Meta Model" )
6161
private boolean generateStaticMetaModelJavaClasses = false;
6262

63-
@CommandLine.Option( names = { "--aspect-prefix", "-prefix" }, description = "Aspect prefix for generated Java class of Aspect" )
64-
private String aspectPrefix = "";
63+
@CommandLine.Option( names = { "--name-prefix", "-namePrefix" }, description = "Name prefix for generated Java class of Aspect" )
64+
private String namePrefix = "";
6565

66-
@CommandLine.Option( names = { "--aspect-postfix", "-postfix" }, description = "Aspect postfix for generated Java class of Aspect" )
67-
private String aspectPostfix = "";
66+
@CommandLine.Option( names = { "--name-postfix", "-namePostfix" }, description = "Name postfix for generated Java class of Aspect" )
67+
private String namePostfix = "";
6868

6969
@CommandLine.ParentCommand
7070
private AspectToCommand parentCommand;
@@ -98,8 +98,8 @@ private JavaCodeGenerationConfig buildConfig( final Aspect aspect ) {
9898
.templateLibFile( templateLibFile )
9999
.enableJacksonAnnotations( !disableJacksonAnnotations )
100100
.packageName( pkgName )
101-
.aspectPrefix( aspectPrefix )
102-
.aspectPostfix( aspectPostfix )
101+
.namePrefix( namePrefix )
102+
.namePostfix( namePostfix )
103103
.build();
104104
}
105105

0 commit comments

Comments
 (0)