Skip to content

Commit 9cfe99a

Browse files
author
synapticloop
committed
removed un-needed import from statistics and naming of files for statistics generation
1 parent 7a26f93 commit 9cfe99a

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/main/java/synapticloop/h2zero/generator/JavaGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private void generateTables(TemplarContext templarContext) throws ParseException
6868

6969
// The model
7070
Parser javaCreateModelParser = getParser("/java-create-model.templar");
71-
Parser javaCreateModelHitcountsParser = getParser("/java-create-model-hitcounts.templar");
71+
Parser javaCreateModelStatisticsParser = getParser("/java-create-model-statistics.templar");
7272

7373
// The table actions
7474
Parser javaCreateFinderParser = getParser("/java-create-finder.templar");
@@ -85,7 +85,7 @@ private void generateTables(TemplarContext templarContext) throws ParseException
8585
renderToFile(templarContext, javaCreateConstantsParser, pathname);
8686

8787
pathname = outFile + options.getOutputCode() + database.getPackagePath() + "/model/util/Statistics.java";
88-
renderToFile(templarContext, javaCreateModelHitcountsParser, pathname);
88+
renderToFile(templarContext, javaCreateModelStatisticsParser, pathname);
8989

9090

9191

src/main/java/synapticloop/h2zero/model/Constant.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
import synapticloop.h2zero.exception.H2ZeroParseException;
2828
import synapticloop.h2zero.model.util.JSONKeyConstants;
2929

30+
/**
31+
* Used when the table is a constant - i.e. no need to go to the database to
32+
* determine what the values are.
33+
*
34+
* @author synapticloop
35+
*
36+
*/
3037
public class Constant {
3138
private List<Object> values = new ArrayList<Object>();
3239
private List<Object> sqlValues = new ArrayList<Object>();
@@ -61,7 +68,7 @@ public Constant(JSONObject constantsObject, Table table) throws H2ZeroParseExcep
6168
}
6269
} else {
6370
sqlValues.add(object);
64-
String stringified = "new " + table.getFields().get(i).getJavaType() + "(" + object + ")";
71+
String stringified = table.getFields().get(i).getJavaType() + ".valueOf(" + object + ")";
6572
values.add(stringified);
6673
if(i == 0) {
6774
this.primaryKeyValue = stringified;

src/main/resources/java-create-model-hitcounts.templar renamed to src/main/resources/java-create-model-statistics.templar

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
package {database.package}.model.util;{\n}{\n}
66
// - - - - thoughtfully generated by synapticloop h2zero - - - - {\n}
77
// with the use of synapticloop templar templating language{\n}
8-
// (java-create-constants.templar){\n}{\n}
8+
// (java-create-model-statistics.templar){\n}{\n}
99

1010
{loop database.tables as table}
11-
import {database.package}.model.{table.javaClassName};{\n}
11+
{if !table.isConstant}
12+
import {database.package}.model.{table.javaClassName};{\n}
13+
{endif}
1214
{endloop}
1315
{\n}
1416
import java.lang.StringBuilder;{\n}

src/main/resources/java-create-model.templar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class {table.javaClassName} {if !table.isConstant}extends ModelBase {endi
8080
And the static HashMap lookup
8181
}
8282

83-
{\t}public static final Map<Long, {table.javaClassName}> ALL_LOOKUP = new HashMap<Long, {table.javaClassName}>();{\n}
83+
{\t}public static final Map<Long, {table.javaClassName}> ALL_LOOKUP = new HashMap<>();{\n}
8484
{\t}static{{{\n}
8585
{loop table.constants as constant}
8686
{\t}{\t}ALL_LOOKUP.put({constant.primaryKeyValue}, {table.javaClassName}.{constant.name});{\n}

0 commit comments

Comments
 (0)