Skip to content

Support for prefixes and suffixes on generated java classes #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8a02542
Testing a maven workflow
agesenm-ELS Oct 12, 2022
7507d14
Update maven.yml
agesenm-ELS Oct 12, 2022
0d19824
Update maven.yml
agesenm-ELS Oct 12, 2022
de89142
Added some missing initialization to a broken test
agesenm-ELS Oct 13, 2022
2fc00a1
Adds configuration for prefixes and suffixes for the generated classes
agesenm-ELS Oct 13, 2022
abba3e4
Adds configuration for prefixes and suffixes for the generated classes
agesenm-ELS Oct 13, 2022
9334e38
Use the java name instead of the graphql name when generating "implem…
agesenm-ELS Oct 13, 2022
79628be
Update maven.yml
agesenm-ELS Oct 13, 2022
fee8412
Merge branch 'master' into prefixes-and-suffixes-for-java-classes
agesenm-ELS Oct 13, 2022
396ad7a
Update maven.yml
agesenm-ELS Oct 13, 2022
900b8ac
Merge branch 'master' into prefixes-and-suffixes-for-java-classes
agesenm-ELS Oct 13, 2022
a7ffbc3
Update maven.yml
agesenm-ELS Oct 13, 2022
e75488c
Merge remote-tracking branch 'origin/master' into prefixes-and-suffix…
agesenm-ELS Oct 13, 2022
1ea35fb
Adds tests for suffix and prefix configuration and code generation
agesenm-ELS Oct 13, 2022
e305295
Typo fix
agesenm-ELS Oct 13, 2022
db1355d
Merge pull request #1 from agesenm-ELS/prefixes-and-suffixes-for-java…
agesenm-ELS Oct 13, 2022
6e699e6
Removed CI workflow
agesenm-ELS Oct 13, 2022
ff0093e
Wiring should map from Graphql type names instead of java names.
agesenm-ELS Oct 14, 2022
b9f1569
Wiring should map from Graphql type names instead of java names.
agesenm-ELS Oct 24, 2022
5d49d48
Merge branch 'graphql-java-generator:master' into master
agesenm-ELS Oct 24, 2022
8ba4074
Prefix-suffix support: Use name() instead of javaName() for utility c…
agesenm-ELS Oct 25, 2022
cbe2159
Prefix-suffix support: Use javaName() instead of name() for @Type ann…
agesenm-ELS Oct 25, 2022
d3dba26
Adds a sub-module for integration that configured prefixes and suffix…
agesenm-ELS Oct 25, 2022
f5cce60
Adds a sub-module for integration that configured prefixes and suffix…
agesenm-ELS Oct 25, 2022
b3564ab
Elaborates documentation of prefix/suffix configuration parameters
agesenm-ELS Oct 25, 2022
fc4f96e
Add a client type mapping generated file for mapping from graphql typ…
agesenm-ELS Nov 1, 2022
1515e94
Use the new generated GraphQLTypeMapping to get the java class for a …
agesenm-ELS Nov 1, 2022
6de62b1
Added prefixes and suffixes to client integration tests
agesenm-ELS Nov 1, 2022
574c986
Added prefixes and suffixes to server integration tests
agesenm-ELS Nov 1, 2022
6dbf813
Removed prefix-suffix module no longer needed after allGraphQLCases c…
agesenm-ELS Nov 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds configuration for prefixes and suffixes for the generated classes
  • Loading branch information
agesenm-ELS committed Oct 13, 2022
commit abba3e44d436be46075b67929e3324dbc5af79a6
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.graphql_java_generator.plugin.DocumentParser;
import com.graphql_java_generator.plugin.conf.CommonConfiguration;
Expand Down Expand Up @@ -86,6 +89,22 @@ public String getClassSimpleName() {
return getJavaName();
}

@Override
public String getJavaName() {
// Optionally add a prefix and/or suffix to the name
String name = Stream.of(getPrefix(), getName(), getSuffix())
.filter(Objects::nonNull).collect(Collectors.joining());

return GraphqlUtils.graphqlUtils.getJavaName(name);
}

protected String getPrefix() {
return "";
}
protected String getSuffix() {
return "";
}

/** {@inheritDoc} */
@Override
public String getCamelCaseName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package com.graphql_java_generator.plugin.language.impl;

Expand Down Expand Up @@ -72,4 +72,14 @@ public boolean isScalar() {
return true;
}

@Override
protected String getPrefix() {
return configuration.getEnumPrefix();
}

@Override
protected String getSuffix() {
return configuration.getEnumSuffix();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ public InterfaceType(String name, CommonConfiguration configuration, DocumentPar
super(name, GraphQlType.INTERFACE, configuration, documentParser);
}

@Override
protected String getPrefix() {
return configuration.getUnionPrefix();
}

@Override
protected String getSuffix() {
return configuration.getUnionSuffix();
}

@Override
public String toString() {
return super.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public String getRequestTypePascalCase() {
return GraphqlUtils.graphqlUtils.getPascalCase(getRequestType());
}

@Override
protected String getPrefix() {
return isInputType() ? getConfiguration().getInputPrefix() : getConfiguration().getTypePrefix();
}

@Override
protected String getSuffix() {
return isInputType() ? getConfiguration().getInputSuffix() : getConfiguration().getTypeSuffix();
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public UnionType(String name, CommonConfiguration configuration, DocumentParser
super(name, GraphQlType.UNION, configuration, documentParser);
}

@Override
protected String getPrefix() {
return configuration.getUnionPrefix();
}

@Override
protected String getSuffix() {
return configuration.getUnionSuffix();
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand Down