Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep
String classVarName = key;
String modelFileName = key.substring(0, 1).toUpperCase() + key.substring(1);
//System.out.println("props = " + Any.wrap(props));

// Check the type of current schema. Generation will be executed only if the type of the schema equals to object.
// Since generate a model for primitive types and arrays do not make sense, and an error class would be generated
// due to lack of properties if force to generate.
if (!"object".equals(type)) {
continue;
}
Comment thread
DSchrupert marked this conversation as resolved.
if(!overwriteModel && checkExist(targetPath, ("src.main.java." + modelPackage).replace(".", separator), modelFileName + ".java")) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import com.jsoniter.any.Any
@import java.util.Map
@import java.util.List
@option discardLogicWhitespace=true

@args (String modelPackage, String className, String classVarName, List<Map<String, Any>> props)
package @modelPackage;
Expand Down Expand Up @@ -37,6 +38,7 @@ public class @className {
}
}
}
@if(props.size() > 0) {

@@Override
public boolean equals(Object o) {
Expand All @@ -57,6 +59,7 @@ public class @className {
return Objects.hash(@for((i, prop): props) {@if(i.index() < props.size() - 1) {@prop.get("name"),} @if(i.index() == props.size() - 1) {@prop.get("name"));}}
}

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