diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-08-31 22:50:14 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-08-31 22:50:14 +0200 |
commit | adcb1d4d55e71d78c662f798b033d3abea0d4b9e (patch) | |
tree | 5867c3ac85792c1578d6ce463e8e24dd2aea7fb0 /configgen | |
parent | 2b83da619a3ee2f38a1a3b05576f44d7451b3daf (diff) |
Add 'model' config type
Diffstat (limited to 'configgen')
18 files changed, 163 insertions, 46 deletions
diff --git a/configgen/src/main/java/com/yahoo/config/codegen/BuilderGenerator.java b/configgen/src/main/java/com/yahoo/config/codegen/BuilderGenerator.java index a0717a1060f..e7b6455f3e0 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/BuilderGenerator.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/BuilderGenerator.java @@ -4,6 +4,7 @@ package com.yahoo.config.codegen; import com.yahoo.config.codegen.LeafCNode.FileLeaf; import com.yahoo.config.codegen.LeafCNode.PathLeaf; import com.yahoo.config.codegen.LeafCNode.UrlLeaf; +import com.yahoo.config.codegen.LeafCNode.ModelLeaf; import java.util.ArrayList; import java.util.List; @@ -274,7 +275,7 @@ public class BuilderGenerator { String type = boxedDataType(n); if ("UrlReference".equals(bType)) type = bType; - stringSetter = String.format("\nprivate Builder %s(String %svalue) {\n" + // + stringSetter = String.format("\nprivate Builder %s(String %svalue) {\n" + " return %s(%s.valueOf(%svalue));\n" + // "}", name, INTERNAL_PREFIX, name, type, INTERNAL_PREFIX); } @@ -282,9 +283,9 @@ public class BuilderGenerator { String getNullGuard = bType.equals(boxedBuilderType(n)) ? String.format( "\nif (%svalue == null) throw new IllegalArgumentException(\"Null value is not allowed.\");", INTERNAL_PREFIX) : ""; - return String.format("public Builder %s(%s %svalue) {%s\n" + // + return String.format("public Builder %s(%s %svalue) {%s\n" + " %s = %svalue;\n" + // - "%s", name, bType, INTERNAL_PREFIX, getNullGuard, name, INTERNAL_PREFIX, signalInitialized) + // + "%s", name, bType, INTERNAL_PREFIX, getNullGuard, name, INTERNAL_PREFIX, signalInitialized) + " return this;" + "\n}\n" + stringSetter; } } @@ -312,6 +313,12 @@ public class BuilderGenerator { return name + "(" + nodeClass(child) + ".toUrlReferenceMap(config." + name + "));"; } else if (child instanceof UrlLeaf) { return name + "(config." + name + ".getUrlReference());"; + } else if (child instanceof ModelLeaf && isArray) { + return name + "(" + nodeClass(child) + ".toModelReferences(config." + name + "));"; + } else if (child instanceof ModelLeaf && isMap) { + return name + "(" + nodeClass(child) + ".toModelReferenceMap(config." + name + "));"; + } else if (child instanceof ModelLeaf) { + return name + "(config." + name + ".getModelReference());"; } else if (child instanceof LeafCNode) { return name + "(config." + name + "());"; } else if (child instanceof InnerCNode && isArray) { @@ -403,6 +410,8 @@ public class BuilderGenerator { return "FileReference"; } else if (node instanceof UrlLeaf) { return "UrlReference"; + } else if (node instanceof ModelLeaf) { + return "ModelReference"; } else if (node instanceof LeafCNode && (node.isArray || node.isMap)) { return boxedDataType(node); } else { @@ -417,6 +426,8 @@ public class BuilderGenerator { return "FileReference"; } else if (node instanceof UrlLeaf) { return "UrlReference"; + } else if (node instanceof ModelLeaf) { + return "ModelReference"; } else { return boxedDataType(node); } diff --git a/configgen/src/main/java/com/yahoo/config/codegen/ClassBuilder.java b/configgen/src/main/java/com/yahoo/config/codegen/ClassBuilder.java index 1ac817e7091..3732791740c 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/ClassBuilder.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/ClassBuilder.java @@ -7,6 +7,6 @@ package com.yahoo.config.codegen; public interface ClassBuilder { /** Generate config class file(s). */ - public void createConfigClasses(); + void createConfigClasses(); } diff --git a/configgen/src/main/java/com/yahoo/config/codegen/ConfigGenerator.java b/configgen/src/main/java/com/yahoo/config/codegen/ConfigGenerator.java index 61bae00e517..fd3aa388ed6 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/ConfigGenerator.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/ConfigGenerator.java @@ -167,6 +167,8 @@ public class ConfigGenerator { return name + " = LeafNodeVector.createPathNodeVector(builder." + name + ");"; } else if (child instanceof UrlLeaf && isArray) { return name + " = LeafNodeVector.createUrlNodeVector(builder." + name + ");"; + } else if (child instanceof ModelLeaf && isArray) { + return name + " = LeafNodeVector.createModelNodeVector(builder." + name + ");"; } else if (child instanceof LeafCNode && isArray) { return name + " = new LeafNodeVector<>(builder." + name + ", new " + className + "());"; } else if (child instanceof FileLeaf && isMap) { @@ -175,6 +177,8 @@ public class ConfigGenerator { return name + " = LeafNodeMaps.asPathNodeMap(builder." + name + ");"; } else if (child instanceof UrlLeaf && isMap) { return name + " = LeafNodeMaps.asUrlNodeMap(builder." + name + ");"; + } else if (child instanceof ModelLeaf && isMap) { + return name + " = LeafNodeMaps.asModelNodeMap(builder." + name + ");"; } else if (child instanceof LeafCNode && isMap) { return name + " = LeafNodeMaps.asNodeMap(builder." + name + ", new " + className + "());"; } else if (child instanceof InnerCNode && isArray) { @@ -399,6 +403,8 @@ public class ConfigGenerator { return "PathNode"; } else if (node instanceof UrlLeaf) { return "UrlNode"; + } else if (node instanceof ModelLeaf) { + return "ModelNode"; } else if (node instanceof IntegerLeaf) { return "IntegerNode"; } else if (node instanceof LongLeaf) { @@ -427,6 +433,8 @@ public class ConfigGenerator { return "Path"; } else if (node instanceof UrlLeaf) { return "File"; + } else if (node instanceof ModelLeaf) { + return "ModelReference"; } else if (node instanceof IntegerLeaf) { return "int"; } else if (node instanceof LongLeaf) { @@ -434,7 +442,7 @@ public class ConfigGenerator { } else if (node instanceof StringLeaf) { return "String"; } else { - throw new IllegalStateException("Cannot determine user data type for node"); // should not occur + throw new IllegalStateException("Cannot determine user data type for node '" + node + "'"); // should not occur } } diff --git a/configgen/src/main/java/com/yahoo/config/codegen/DefLine.java b/configgen/src/main/java/com/yahoo/config/codegen/DefLine.java index eeca50201b7..753fad0d41a 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/DefLine.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/DefLine.java @@ -251,7 +251,7 @@ public class DefLine { } else if (whitespaceMatcher.matches()) { break; } else { - throw new IllegalArgumentException(name + " contains unexpected character"); + throw new IllegalArgumentException("'" + name + "' contains an unexpected character"); } } } diff --git a/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java b/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java index cebb7ca8108..2be824658b4 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/DefParser.java @@ -210,7 +210,7 @@ public class DefParser { sb.append(" = ").append(((LeafCNode)root).getDefaultValue().getValue()); } } - System.out.println(sb.toString()); + System.out.println(sb); if (!root.getComment().isEmpty()) { String comment = root.getComment(); if (comment.contains("\n")) { diff --git a/configgen/src/main/java/com/yahoo/config/codegen/DefaultValue.java b/configgen/src/main/java/com/yahoo/config/codegen/DefaultValue.java index 9d8ee58f364..ed68bb7d9d8 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/DefaultValue.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/DefaultValue.java @@ -13,30 +13,22 @@ public class DefaultValue { // The variable type. Always set UNLESS the value is null. private DefLine.Type type = null; - /** - * Null value - */ + /** Null value. */ public DefaultValue() { } - /** - * A default value with the given value and type. - */ + /** A default value with the given value and type. */ public DefaultValue(String value, DefLine.Type type) { this.value = value; this.type = type; } - /** - * Returns the toString of the default value. - */ + /** Returns the toString of the default value. */ public String getValue() { return value; } - /** - * Returns the string representation of this value - */ + /** Returns the string representation of this value. */ public String getStringRepresentation() { if (value == null) return "null"; @@ -60,7 +52,7 @@ public class DefaultValue { sb.append(c); } } - return "\"" + sb.toString() + "\""; + return "\"" + sb + "\""; } } diff --git a/configgen/src/main/java/com/yahoo/config/codegen/InnerCNode.java b/configgen/src/main/java/com/yahoo/config/codegen/InnerCNode.java index 74b0bbf7bba..295558a469c 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/InnerCNode.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/InnerCNode.java @@ -15,7 +15,7 @@ public class InnerCNode extends CNode { * The children of this Node. Mapped using their short name as * string. This variable is null only if Node is a leaf Node. */ - private final Map<String, CNode> children = new LinkedHashMap<String, CNode>(); + private final Map<String, CNode> children = new LinkedHashMap<>(); private boolean restart = false; /** @@ -66,8 +66,7 @@ public class InnerCNode extends CNode { } else { newChild = LeafCNode.newInstance(type, this, key); if (newChild == null) - throw new IllegalArgumentException - ("Could not create " + type.name + " " + name); + throw new IllegalArgumentException("Could not create " + type.name + " " + name); } return children.containsKey(newChild.getName()) ? children.get(newChild.getName()) @@ -77,6 +76,7 @@ public class InnerCNode extends CNode { /** * Adds a child to this node with the given type, name and value. Necessary children on the path * to the given leaf node will be added as well. + * * @param name the full name/path of the node to add. * @param defLine the parsed .def-file line to add. * @param comment comment extracted from the .def-file. diff --git a/configgen/src/main/java/com/yahoo/config/codegen/JavaClassBuilder.java b/configgen/src/main/java/com/yahoo/config/codegen/JavaClassBuilder.java index fe1566aa133..4141a3b6e09 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/JavaClassBuilder.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/JavaClassBuilder.java @@ -105,12 +105,9 @@ public class JavaClassBuilder implements ClassBuilder { } /** - * @param rootDir - * The root directory for the destination path. - * @param javaPackage - * The java package - * @return the destination path for the generated config file, including the - * given rootDir. + * @param rootDir the root directory for the destination path. + * @param javaPackage the java package + * @return the destination path for the generated config file, including the given rootDir. */ private File getDestPath(File rootDir, String javaPackage) { File dir = rootDir; diff --git a/configgen/src/main/java/com/yahoo/config/codegen/LeafCNode.java b/configgen/src/main/java/com/yahoo/config/codegen/LeafCNode.java index e3d2cdb5a36..1395c6814df 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/LeafCNode.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/LeafCNode.java @@ -74,8 +74,7 @@ public abstract class LeafCNode extends CNode { } @Override - protected void setLeaf(String name, DefLine defLine, String comment) - throws IllegalArgumentException { + protected void setLeaf(String name, DefLine defLine, String comment) throws IllegalArgumentException { DefLine.Type type = defLine.getType(); // TODO: why the !is... conditions? if (!isMap && !isArray && isInitialized) { @@ -101,8 +100,7 @@ public abstract class LeafCNode extends CNode { checkDefaultValue(defaultValue); setDefaultValue(defaultValue); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException - ("Invalid default value", e); + throw new IllegalArgumentException("Invalid default value", e); } } diff --git a/configgen/src/main/java/com/yahoo/config/codegen/MakeConfig.java b/configgen/src/main/java/com/yahoo/config/codegen/MakeConfig.java index 04f7c90c9b9..a24d88102bd 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/MakeConfig.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/MakeConfig.java @@ -98,9 +98,9 @@ public class MakeConfig { static class Exceptions { /** - * <p>Returns a use friendly error message string which includes information from all nested exceptions. + * Returns a use friendly error message string which includes information from all nested exceptions. * - * <p>The form of this string is + * The form of this string is * <code>e.getMessage(): e.getCause().getMessage(): e.getCause().getCause().getMessage()...</code> * In addition, some heuristics are used to clean up common cases where exception nesting causes bad messages. */ diff --git a/configgen/src/main/java/com/yahoo/config/codegen/NormalizedDefinition.java b/configgen/src/main/java/com/yahoo/config/codegen/NormalizedDefinition.java index fde9c171546..5d36b3cb77d 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/NormalizedDefinition.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/NormalizedDefinition.java @@ -23,7 +23,7 @@ public class NormalizedDefinition { // Patterns used for finding ranges in config definitions private static final Pattern intPattern = Pattern.compile(".*int.*range.*"); private static final Pattern doublePattern = Pattern.compile(".*double.*range.*"); - private MessageDigest md5; + private final MessageDigest md5; String defMd5 = null; List<String> normalizedContent = null; @@ -61,8 +61,8 @@ public class NormalizedDefinition { * </ul> * The supplied list is changed in-place * - * @param line A config definition line - * @return a normalized config definition line + * @param line a config definition line + * @return a normalized config definition line */ public static String normalize(String line) { //System.out.println("before line=" + line + ";"); @@ -150,7 +150,8 @@ public class NormalizedDefinition { } /** - * Replaces sequences of spaces with 1 space, unless inside quotes. Public for testing; + * Replaces sequences of spaces with 1 space, unless inside quotes. Public for testing. + * * @param str String to strip spaces from * @return String with spaces stripped */ @@ -186,6 +187,7 @@ public class NormalizedDefinition { return normalizedContent; } + @Override public String toString() { StringBuilder builder = new StringBuilder(); for (String line : normalizedContent) { diff --git a/configgen/src/main/java/com/yahoo/config/codegen/ReservedWords.java b/configgen/src/main/java/com/yahoo/config/codegen/ReservedWords.java index 3310ceb30f5..15465bccae3 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/ReservedWords.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/ReservedWords.java @@ -44,7 +44,7 @@ public class ReservedWords { private static final HashMap<String, String> allKeyWords; static { - allKeyWords = new HashMap<String, String>(); + allKeyWords = new HashMap<>(); for (String s : cKeywords) { allKeyWords.put(s, "C"); } diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java index 53d02689fed..0e2f6cc4d05 100644 --- a/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java +++ b/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java @@ -121,6 +121,13 @@ public class DefLineParsingTest { assertEquals("url", l.getType().getName()); } + @Test + void testParseModels() { + DefLine l = new DefLine("modelVal model"); + + assertEquals("modelVal", l.getName()); + assertEquals("model", l.getType().getName()); + } @Test void testParseDefaultInt() { diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java index 4fbf01892cc..45d1f21763c 100644 --- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java +++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java @@ -28,7 +28,7 @@ public class DefParserTest { CNode root = new DefParser("test", new FileReader(defFile)).getTree(); assertNotNull(root); CNode[] children = root.getChildren(); - assertEquals(34, children.length); + assertEquals(37, children.length); int numGrandChildren = 0; int numGreatGrandChildren = 0; @@ -70,7 +70,7 @@ public class DefParserTest { void testMd5Sum() throws IOException { File defFile = new File(DEF_NAME); CNode root = new DefParser("test", new FileReader(defFile)).getTree(); - assertEquals("f901bdc5c96e7005130399c63f247823", root.defMd5); + assertEquals("0501f9e2c4ecc8c283e100e0b1178ca4", root.defMd5); } @Test @@ -194,7 +194,7 @@ public class DefParserTest { @Test void testIllegalCharacterInName() { assertLineFails("a-b int", - "a-b contains unexpected character"); + "'a-b' contains an unexpected character"); } @Test diff --git a/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java b/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java index 69a690b0e82..428576e340f 100644 --- a/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java +++ b/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java @@ -33,6 +33,7 @@ public class JavaClassBuilderTest { "pathArr[] path\n" + // "u url\n" + // "urlArr[] url\n" + // + "modelArr[] model\n" + // "f file\n" + // "fileArr[] file\n" + // "i int default=0\n" + // diff --git a/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java b/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java index 61b5eb5a759..57b3ed962eb 100644 --- a/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java +++ b/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java @@ -70,7 +70,7 @@ public class NormalizedDefinitionTest { } assertNotNull(out); - assertEquals(72, out.size()); + assertEquals(75, out.size()); assertNotNull(fileReader); fileReader.close(); diff --git a/configgen/src/test/resources/allfeatures.reference b/configgen/src/test/resources/allfeatures.reference index 6ebcfc4ba12..0961d3aa922 100644 --- a/configgen/src/test/resources/allfeatures.reference +++ b/configgen/src/test/resources/allfeatures.reference @@ -35,7 +35,7 @@ import com.yahoo.config.*; */ public final class AllfeaturesConfig extends ConfigInstance { - public final static String CONFIG_DEF_MD5 = "f901bdc5c96e7005130399c63f247823"; + public final static String CONFIG_DEF_MD5 = "0501f9e2c4ecc8c283e100e0b1178ca4"; public final static String CONFIG_DEF_NAME = "allfeatures"; public final static String CONFIG_DEF_NAMESPACE = "configgen"; public final static String[] CONFIG_DEF_SCHEMA = { @@ -57,6 +57,7 @@ public final class AllfeaturesConfig extends ConfigInstance { "fileVal file", "pathVal path", "urlVal url", + "modelVal model", "boolarr[] bool", "intarr[] int", "longarr[] long", @@ -67,9 +68,11 @@ public final class AllfeaturesConfig extends ConfigInstance { "filearr[] file", "pathArr[] path", "urlArr[] url", + "modelArr[] model", "intMap{} int", "pathMap{} file", "urlMap{} url", + "modelMap{} model", "basic_struct.foo string default=\"foo\"", "basic_struct.bar int default=0", "struct_of_struct.inner0.name string default=\"inner0\"", @@ -107,7 +110,8 @@ public final class AllfeaturesConfig extends ConfigInstance { "refVal", "fileVal", "pathVal", - "urlVal" + "urlVal", + "modelVal" )); private Boolean boolVal = null; @@ -127,6 +131,7 @@ public final class AllfeaturesConfig extends ConfigInstance { private String fileVal = null; private FileReference pathVal = null; private UrlReference urlVal = null; + private ModelReference modelVal = null; public List<Boolean> boolarr = new ArrayList<>(); public List<Integer> intarr = new ArrayList<>(); public List<Long> longarr = new ArrayList<>(); @@ -137,9 +142,11 @@ public final class AllfeaturesConfig extends ConfigInstance { public List<String> filearr = new ArrayList<>(); public List<FileReference> pathArr = new ArrayList<>(); public List<UrlReference> urlArr = new ArrayList<>(); + public List<ModelReference> modelArr = new ArrayList<>(); public Map<String, Integer> intMap = new LinkedHashMap<>(); public Map<String, String> pathMap = new LinkedHashMap<>(); public Map<String, UrlReference> urlMap = new LinkedHashMap<>(); + public Map<String, ModelReference> modelMap = new LinkedHashMap<>(); public Basic_struct.Builder basic_struct = new Basic_struct.Builder(); public Struct_of_struct.Builder struct_of_struct = new Struct_of_struct.Builder(); public List<MyArray.Builder> myArray = new ArrayList<>(); @@ -165,6 +172,7 @@ public final class AllfeaturesConfig extends ConfigInstance { fileVal(config.fileVal().value()); pathVal(config.pathVal.getFileReference()); urlVal(config.urlVal.getUrlReference()); + modelVal(config.modelVal.getModelReference()); boolarr(config.boolarr()); intarr(config.intarr()); longarr(config.longarr()); @@ -175,9 +183,11 @@ public final class AllfeaturesConfig extends ConfigInstance { filearr(FileReference.toValues(config.filearr())); pathArr(PathNode.toFileReferences(config.pathArr)); urlArr(UrlNode.toUrlReferences(config.urlArr)); + modelArr(ModelNode.toModelReferences(config.modelArr)); intMap(config.intMap()); pathMap(FileReference.toValueMap(config.pathMap())); urlMap(UrlNode.toUrlReferenceMap(config.urlMap)); + modelMap(ModelNode.toModelReferenceMap(config.modelMap)); basic_struct(new Basic_struct.Builder(config.basic_struct())); struct_of_struct(new Struct_of_struct.Builder(config.struct_of_struct())); for (MyArray m : config.myArray()) { @@ -223,6 +233,8 @@ public final class AllfeaturesConfig extends ConfigInstance { pathVal(__superior.pathVal); if (__superior.urlVal != null) urlVal(__superior.urlVal); + if (__superior.modelVal != null) + modelVal(__superior.modelVal); if (!__superior.boolarr.isEmpty()) boolarr.addAll(__superior.boolarr); if (!__superior.intarr.isEmpty()) @@ -243,9 +255,12 @@ public final class AllfeaturesConfig extends ConfigInstance { pathArr.addAll(__superior.pathArr); if (!__superior.urlArr.isEmpty()) urlArr.addAll(__superior.urlArr); + if (!__superior.modelArr.isEmpty()) + modelArr.addAll(__superior.modelArr); intMap(__superior.intMap); pathMap(__superior.pathMap); urlMap(__superior.urlMap); + modelMap(__superior.modelMap); basic_struct(basic_struct.override(__superior.basic_struct)); struct_of_struct(struct_of_struct.override(__superior.struct_of_struct)); if (!__superior.myArray.isEmpty()) @@ -408,6 +423,17 @@ public final class AllfeaturesConfig extends ConfigInstance { return urlVal(UrlReference.valueOf(__value)); } + public Builder modelVal(ModelReference __value) { + if (__value == null) throw new IllegalArgumentException("Null value is not allowed."); + modelVal = __value; + __uninitialized.remove("modelVal"); + return this; + } + + private Builder modelVal(String __value) { + return modelVal(ModelReference.valueOf(__value)); + } + public Builder boolarr(Boolean __value) { boolarr.add(__value); return this; @@ -532,6 +558,20 @@ public final class AllfeaturesConfig extends ConfigInstance { return urlArr(UrlReference.valueOf(__value)); } + public Builder modelArr(ModelReference __value) { + modelArr.add(__value); + return this; + } + + public Builder modelArr(Collection<ModelReference> __values) { + modelArr.addAll(__values); + return this; + } + + private Builder modelArr(String __value) { + return modelArr(ModelReference.valueOf(__value)); + } + public Builder intMap(String __key, Integer __value) { intMap.put(__key, __value); return this; @@ -570,6 +610,20 @@ public final class AllfeaturesConfig extends ConfigInstance { return urlMap(__key, UrlReference.valueOf(__value)); } + public Builder modelMap(String __key, ModelReference __value) { + modelMap.put(__key, __value); + return this; + } + + public Builder modelMap(Map<String, ModelReference> __values) { + modelMap.putAll(__values); + return this; + } + + private Builder modelMap(String __key, String __value) { + return modelMap(__key, ModelReference.valueOf(__value)); + } + public Builder basic_struct(Basic_struct.Builder __builder) { basic_struct = __builder; return this; @@ -709,6 +763,7 @@ public final class AllfeaturesConfig extends ConfigInstance { private final FileNode fileVal; private final PathNode pathVal; private final UrlNode urlVal; + private final ModelNode modelVal; private final LeafNodeVector<Boolean, BooleanNode> boolarr; private final LeafNodeVector<Integer, IntegerNode> intarr; private final LeafNodeVector<Long, LongNode> longarr; @@ -719,9 +774,11 @@ public final class AllfeaturesConfig extends ConfigInstance { private final LeafNodeVector<FileReference, FileNode> filearr; private final LeafNodeVector<Path, PathNode> pathArr; private final LeafNodeVector<File, UrlNode> urlArr; + private final LeafNodeVector<ModelReference, ModelNode> modelArr; private final Map<String, IntegerNode> intMap; private final Map<String, FileNode> pathMap; private final Map<String, UrlNode> urlMap; + private final Map<String, ModelNode> modelMap; private final Basic_struct basic_struct; private final Struct_of_struct struct_of_struct; private final InnerNodeVector<MyArray> myArray; @@ -770,6 +827,8 @@ public final class AllfeaturesConfig extends ConfigInstance { new PathNode() : new PathNode(builder.pathVal); urlVal = (builder.urlVal == null) ? new UrlNode() : new UrlNode(builder.urlVal); + modelVal = (builder.modelVal == null) ? + new ModelNode() : new ModelNode(builder.modelVal); boolarr = new LeafNodeVector<>(builder.boolarr, new BooleanNode()); intarr = new LeafNodeVector<>(builder.intarr, new IntegerNode()); longarr = new LeafNodeVector<>(builder.longarr, new LongNode()); @@ -780,9 +839,11 @@ public final class AllfeaturesConfig extends ConfigInstance { filearr = LeafNodeVector.createFileNodeVector(builder.filearr); pathArr = LeafNodeVector.createPathNodeVector(builder.pathArr); urlArr = LeafNodeVector.createUrlNodeVector(builder.urlArr); + modelArr = LeafNodeVector.createModelNodeVector(builder.modelArr); intMap = LeafNodeMaps.asNodeMap(builder.intMap, new IntegerNode()); pathMap = LeafNodeMaps.asFileNodeMap(builder.pathMap); urlMap = LeafNodeMaps.asUrlNodeMap(builder.urlMap); + modelMap = LeafNodeMaps.asModelNodeMap(builder.modelMap); basic_struct = new Basic_struct(builder.basic_struct, throwIfUninitialized); struct_of_struct = new Struct_of_struct(builder.struct_of_struct, throwIfUninitialized); myArray = MyArray.createVector(builder.myArray); @@ -909,6 +970,13 @@ public final class AllfeaturesConfig extends ConfigInstance { } /** + * @return allfeatures.modelVal + */ + public ModelReference modelVal() { + return modelVal.value(); + } + + /** * @return allfeatures.boolarr[] */ public List<Boolean> boolarr() { @@ -1059,6 +1127,21 @@ public final class AllfeaturesConfig extends ConfigInstance { } /** + * @return allfeatures.modelArr[] + */ + public List<ModelReference> modelArr() { + return modelArr.asList(); + } + + /** + * @param i the index of the value to return + * @return allfeatures.modelArr[] + */ + public ModelReference modelArr(int i) { + return modelArr.get(i).value(); + } + + /** * @return allfeatures.intMap{} */ public Map<String, Integer> intMap() { @@ -1104,6 +1187,21 @@ public final class AllfeaturesConfig extends ConfigInstance { } /** + * @return allfeatures.modelMap{} + */ + public Map<String, ModelReference> modelMap() { + return LeafNodeMaps.asValueMap(modelMap); + } + + /** + * @param key the key of the value to return + * @return allfeatures.modelMap{} + */ + public ModelReference modelMap(String key) { + return modelMap.get(key).value(); + } + + /** * @return allfeatures.basic_struct */ public Basic_struct basic_struct() { diff --git a/configgen/src/test/resources/configgen.allfeatures.def b/configgen/src/test/resources/configgen.allfeatures.def index df20665f1b7..1f93e29b73b 100644 --- a/configgen/src/test/resources/configgen.allfeatures.def +++ b/configgen/src/test/resources/configgen.allfeatures.def @@ -40,6 +40,7 @@ refwithdef reference default=":parent:" fileVal file pathVal path urlVal url +modelVal model boolarr[] bool intarr[] int @@ -51,10 +52,12 @@ refarr[] reference filearr[] file pathArr[] path urlArr[] url +modelArr[] model intMap{} int pathMap{} file urlMap{} url +modelMap{} model # A basic struct basic_struct.foo string default="foo" |