diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java index 6b314203b..515387585 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java @@ -209,17 +209,17 @@ public Exports(@NonNull List importedModules) { // as an imported one Map exportedFlagDefinitions = flags.collect( CustomCollectors.toMap( - IFlagDefinition::getXmlQName, + IFlagDefinition::getDefinitionQName, CustomCollectors.identity(), AbstractModule::handleShadowedDefinitions)); Map exportedFieldDefinitions = fields.collect( CustomCollectors.toMap( - IFieldDefinition::getXmlQName, + IFieldDefinition::getDefinitionQName, CustomCollectors.identity(), AbstractModule::handleShadowedDefinitions)); Map exportedAssemblyDefinitions = assemblies.collect( CustomCollectors.toMap( - IAssemblyDefinition::getXmlQName, + IAssemblyDefinition::getDefinitionQName, CustomCollectors.identity(), AbstractModule::handleShadowedDefinitions)); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractNamedInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractNamedInstance.java index 3f33fc4ca..e651b9ee9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractNamedInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractNamedInstance.java @@ -47,7 +47,9 @@ public abstract class AbstractNamedInstance< * Construct a new instance. * * @param parent - * the parent containing the instance. + * the parent containing the instance + * @param initializer + * used to generate the instance qualified name */ protected AbstractNamedInstance(@NonNull PARENT parent, @NonNull NameInitializer initializer) { super(parent); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelDefinition.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelDefinition.java index 6a458e88a..2d8317dda 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelDefinition.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelDefinition.java @@ -66,7 +66,6 @@ default boolean hasChildren() { * * @return the flag instance if a JSON key is configured, or {@code null} * otherwise - * @see #hasJsonKey() */ // TODO: remove once moved to the instance side // TODO: Reconsider using toFlagName in favor of getReferencedDefinitionQName diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java index 63d96cfc1..8e259c499 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java @@ -46,9 +46,9 @@ * can be accessed using {@link #getImportedModules()}. *

* Global scoped Metaschema definitions can be accessed using - * {@link #getScopedAssemblyDefinitionByName(String)}, - * {@link #getScopedFieldDefinitionByName(String)}, and - * {@link #getScopedFlagDefinitionByName(String)}. These methods take into + * {@link #getScopedAssemblyDefinitionByName(QName)}, + * {@link #getScopedFieldDefinitionByName(QName)}, and + * {@link #getScopedFlagDefinitionByName(QName)}. These methods take into * consideration the import order to provide the global definitions that are in * scope within the given Metschema module. *

diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstance.java index 6d8788378..47c14c813 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstance.java @@ -42,11 +42,11 @@ public interface INamedModelInstance extends IModelInstance, INamedInstance { * cases, the flag will not appear in the object. This is only allowed if the * flag is required, as determined by a {@code true} result from * {@link IFlagInstance#isRequired()}. The {@link IFlagInstance} can be - * retrieved using {@link #getJsonKeyFlagInstance()}. + * retrieved using {@link #getEffectiveJsonKey()}. * * @return {@code true} if the flag's value can be used as a property name, or * {@code false} otherwise - * @see #getJsonKeyFlagInstance() + * @see #getEffectiveJsonKey() */ // TODO: remove once moved to the instance side default boolean hasJsonKey() { diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/ExamplesTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/ExamplesTest.java index bc8d51714..dad9cc9dc 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/ExamplesTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/model/xml/ExamplesTest.java @@ -62,7 +62,7 @@ void testExamineAssemblyDefinitionByName() throws MetaschemaException, IOExcepti IMetaschemaModule module = loader.load(moduleUri); IAssemblyDefinition definition = module.getScopedAssemblyDefinitionByName( - new QName("http://csrc.nist.gov/ns/oscal/1.0", "prop")); + new QName("http://csrc.nist.gov/ns/oscal/1.0", "property")); assertNotNull(definition, "definition not found"); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java index 642f26f63..c7b5ca36c 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java @@ -316,6 +316,8 @@ default IConstraintValidator newValidator(@NonNull IConstraintValidationHandler * * @param nodeItem * the node item to validate + * @param loader + * a module loader used to load and resolve referenced resources * @return the validation result * @throws IllegalArgumentException * if the provided class is not bound to a Module assembly or field diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ClassUtils.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ClassUtils.java index 6953cc97d..be18276b6 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ClassUtils.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ClassUtils.java @@ -26,7 +26,9 @@ package gov.nist.secauto.metaschema.databind.codegen; -import gov.nist.secauto.metaschema.databind.codegen.impl.NameConverter; +import org.apache.xmlbeans.impl.common.NameUtil; + +import java.util.Map; import edu.umd.cs.findbugs.annotations.NonNull; @@ -34,6 +36,9 @@ * A variety of utility methods for normalizing Java class related names. */ public final class ClassUtils { + private static final Map JAVA_NAME_MAPPER = Map.ofEntries( + Map.entry("Class", "Clazz")); + private ClassUtils() { // disable construction } @@ -49,7 +54,8 @@ private ClassUtils() { @SuppressWarnings("null") @NonNull public static String toPropertyName(@NonNull String name) { - return NameConverter.STANDARD.toPropertyName(name); + String property = NameUtil.upperCamelCase(name); + return JAVA_NAME_MAPPER.getOrDefault(property, property); } /** @@ -63,7 +69,7 @@ public static String toPropertyName(@NonNull String name) { @SuppressWarnings("null") @NonNull public static String toVariableName(@NonNull String name) { - return NameConverter.STANDARD.toVariableName(name); + return NameUtil.lowerCamelCase(name); } /** @@ -77,7 +83,7 @@ public static String toVariableName(@NonNull String name) { @SuppressWarnings("null") @NonNull public static String toClassName(@NonNull String name) { - return NameConverter.STANDARD.toClassName(name); + return NameUtil.upperCamelCase(name, false); } /** @@ -91,7 +97,6 @@ public static String toClassName(@NonNull String name) { @SuppressWarnings("null") @NonNull public static String toPackageName(@NonNull String name) { - return NameConverter.STANDARD.toPackageName(name); + return NameUtil.getPackageFromNamespace(name, false); } - } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/NameConverter.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/NameConverter.java deleted file mode 100644 index 709db26f5..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/NameConverter.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ -/* - * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0, which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -package gov.nist.secauto.metaschema.databind.codegen.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.StringTokenizer; - -import javax.lang.model.SourceVersion; - -/** - * Converts aribitrary strings into Java identifiers. - * - * @author Kohsuke KAWAGUCHI - */ -public interface NameConverter { - /** - * The name converter implemented by Code Model. - * - * This is the standard name conversion for JAXB. - */ - NameConverter STANDARD = new Standard(); - - /** - * converts a string into an identifier suitable for classes. - * - * In general, this operation should generate "NamesLikeThis". - * - * @param token - * the string to convert - * @return the equivalent class name - */ - String toClassName(String token); - - /** - * converts a string into an identifier suitable for interfaces. - * - * In general, this operation should generate "NamesLikeThis". But for example, - * it can prepend every interface with 'I'. - * - * @param token - * the string to convert - * @return the equivalent interface name - */ - String toInterfaceName(String token); - - /** - * Converts a string into an identifier suitable for Java properties. - *

- * In general, this operation should generate upper camel case "NamesLikeThis", - * which will be used with known prefixes like "get" or "set". - * - * @param token - * the string to convert - * @return the equivalent Java property name - */ - String toPropertyName(String token); - - /** - * converts a string into an identifier suitable for constants. - *

- * In the standard Java naming convention, this operation should generate upper - * case "NAMES_LIKE_THIS". - * - * @param token - * the string to convert - * @return the equivalent constant name - */ - String toConstantName(String token); - - /** - * Converts a string into an identifier suitable for variables. - *

- * In general it should generate lower camel case "namesLikeThis". - * - * @param token - * the string to convert - * @return the equivalent variable name - */ - String toVariableName(String token); - - /** - * Converts a namespace URI into a package name. This method should expect - * strings like "http://foo.bar.zot/org", "urn:abc:def:ghi" "", or even "###" - * (basically anything) and expected to return a package name, like - * "org.acme.foo". - * - * @param namespaceUri - * the string to convert - * @return the equivalent package name - */ - String toPackageName(String namespaceUri); - - class Standard - extends NameUtil - implements NameConverter { - - @Override - public String toClassName(String token) { - return toMixedCaseName(toWordList(token), true); - } - - @Override - public String toVariableName(String token) { - return toMixedCaseName(toWordList(token), false); - } - - @Override - public String toInterfaceName(String token) { - return toClassName(token); - } - - @Override - public String toPropertyName(String token) { - String prop = toClassName(token); - // property name "Class" with collide with Object.getClass, - // so escape this. - if ("Class".equals(prop)) { - prop = "Clazz"; - } - return prop; - } - - /** - * Computes a Java package name from a namespace URI, as specified in the spec. - * - * @return {@code null} if it fails to derive a package name. - */ - @SuppressWarnings({ - "PMD.CyclomaticComplexity", "PMD.NPathComplexity", // acceptable - "PMD.OnlyOneReturn", // readability - "PMD.UseStringBufferForStringAppends" // ok - }) - @Override - public String toPackageName(String uri) { - String nsUri = uri; - // remove scheme and :, if present - // spec only requires us to remove 'http' and 'urn'... - int idx = nsUri.indexOf(':'); - String scheme = ""; - if (idx >= 0) { - scheme = nsUri.substring(0, idx); - if ("http".equalsIgnoreCase(scheme) || "urn".equalsIgnoreCase(scheme)) { - nsUri = nsUri.substring(idx + 1); - } - } - - // tokenize string - List tokens = tokenize(nsUri, "/: "); - if (tokens.isEmpty()) { - return null; - } - - // remove trailing file type, if necessary - if (tokens.size() > 1) { - // for uri's like "www.foo.com" and "foo.com", there is no trailing - // file, so there's no need to look at the last '.' and substring - // otherwise, we loose the "com" (which would be wrong) - String lastToken = tokens.get(tokens.size() - 1); - idx = lastToken.lastIndexOf('.'); - if (idx > 0) { - lastToken = lastToken.substring(0, idx); - tokens.set(tokens.size() - 1, lastToken); - } - } - - // tokenize domain name and reverse. Also remove :port if it exists - String domain = tokens.get(0); - idx = domain.indexOf(':'); - if (idx >= 0) { - domain = domain.substring(0, idx); - } - List rev = reverse(tokenize(domain, "urn".equals(scheme) ? ".-" : ".")); - if ("www".equalsIgnoreCase(rev.get(rev.size() - 1))) { - // remove leading www - rev.remove(rev.size() - 1); - } - - // replace the domain name with tokenized items - tokens.addAll(1, rev); - tokens.remove(0); - - // iterate through the tokens and apply xml->java name algorithm - for (int i = 0; i < tokens.size(); i++) { - - // get the token and remove illegal chars - String token = tokens.get(i); - token = removeIllegalIdentifierChars(token); - - // this will check for reserved keywords - if (SourceVersion.isKeyword(token.toLowerCase(Locale.ENGLISH))) { - token = '_' + token; - } - - tokens.set(i, token.toLowerCase(Locale.ENGLISH)); - } - - // concat all the pieces and return it - return combine(tokens, '.'); - } - - private static String removeIllegalIdentifierChars(String token) { - StringBuilder newToken = new StringBuilder(token.length() * 2); // max expected length - for (int i = 0; i < token.length(); i++) { - char ch = token.charAt(i); - if (i == 0 && !Character.isJavaIdentifierStart(ch)) { // ch can't be used as FIRST char - newToken.append('_'); - } - if (Character.isJavaIdentifierPart(ch)) { - newToken.append(ch); // ch is valid - } else { - newToken.append('_'); // ch can't be used - } - } - return newToken.toString(); - } - - private static List tokenize(String str, String sep) { - StringTokenizer tokens = new StringTokenizer(str, sep); - List retval = new ArrayList<>(); - - while (tokens.hasMoreTokens()) { - retval.add(tokens.nextToken()); - } - return retval; - } - - private static List reverse(List list) { - List rev = new ArrayList<>(list.size()); - - for (int i = list.size() - 1; i >= 0; i--) { - rev.add(list.get(i)); - } - return rev; - } - - private static String combine(List tokens, char sep) { - StringBuilder buf = new StringBuilder(tokens.get(0)); - - for (int i = 1; i < tokens.size(); i++) { - buf.append(sep) - .append(tokens.get(i)); - } - return buf.toString(); - } - } -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/NameUtil.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/NameUtil.java deleted file mode 100644 index c54f0d736..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/NameUtil.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ - -/* - * This code is based on https://github.com/eclipse-ee4j/jaxb-ri/blob/master/jaxb-ri/core/src/main/java/org/glassfish/jaxb/core/api/impl/NameUtil.java - * - * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0, which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -package gov.nist.secauto.metaschema.databind.codegen.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -/** - * Methods that convert strings into various formats. - */ -@SuppressWarnings("PMD") -class NameUtil { - protected static boolean isPunct(char ch) { - return ch == '-' || ch == '.' || ch == ':' || ch == '_' || ch == '·' || ch == '·' || ch == '۝' || ch == '۞'; - } - - /** - * Capitalizes the first character of the specified string, and de-capitalize - * the rest of characters. - * - * @param str - * the string to capitalize - * @return the capitalized string - */ - public static String capitalize(String str) { - if (!Character.isLowerCase(str.charAt(0))) { - return str; - } - StringBuilder sb = new StringBuilder(str.length()); - sb.append(String.valueOf(str.charAt(0)).toUpperCase(Locale.ENGLISH)); - sb.append(str.substring(1).toLowerCase(Locale.ENGLISH)); - return sb.toString(); - } - - // Precondition: s[start] is not punctuation - @SuppressWarnings({ - "checkstyle:MissingSwitchDefaultCheck", // intentional - }) - private static int nextBreak(String str, int start) { - int len = str.length(); - - char c1 = str.charAt(start); - int t1 = classify(c1); - - for (int i = start + 1; i < len; i++) { - // shift (c1,t1) into (c0,t0) - // char c0 = c1; --- conceptually, but c0 won't be used - int t0 = t1; - - c1 = str.charAt(i); - t1 = classify(c1); - - switch (actionTable[t0 * 5 + t1]) { - case ACTION_CHECK_PUNCT: - if (isPunct(c1)) { - return i; - } - break; - case ACTION_CHECK_C2: - if (i < len - 1) { - char c2 = str.charAt(i + 1); - if (Character.isLowerCase(c2)) { - return i; - } - } - break; - case ACTION_BREAK: - return i; - } - } - return -1; - } - - // the 5-category classification that we use in this code - // to find work breaks - protected static final int UPPER_LETTER = 0; - protected static final int LOWER_LETTER = 1; - protected static final int OTHER_LETTER = 2; - protected static final int DIGIT = 3; - protected static final int OTHER = 4; - - /** - * Look up table for actions. type0*5+type1 would yield the action to be taken. - */ - private static final byte[] actionTable = new byte[5 * 5]; - - // action constants. see nextBreak for the meaning - private static final byte ACTION_CHECK_PUNCT = 0; - private static final byte ACTION_CHECK_C2 = 1; - private static final byte ACTION_BREAK = 2; - private static final byte ACTION_NOBREAK = 3; - - /** - * Decide the action to be taken given the classification of the preceding - * character 't0' and the classification of the next character 't1'. - */ - private static byte decideAction(int t0, int t1) { - if (t0 == OTHER && t1 == OTHER) { - return ACTION_CHECK_PUNCT; - } - if ((t0 == DIGIT) ^ (t1 == DIGIT)) { - return ACTION_BREAK; - } - if (t0 == LOWER_LETTER && t1 != LOWER_LETTER) { - return ACTION_BREAK; - } - if ((t0 <= OTHER_LETTER) ^ (t1 <= OTHER_LETTER)) { - return ACTION_BREAK; - } - if ((t0 == OTHER_LETTER) ^ (t1 == OTHER_LETTER)) { - return ACTION_BREAK; - } - if (t0 == UPPER_LETTER && t1 == UPPER_LETTER) { - return ACTION_CHECK_C2; - } - - return ACTION_NOBREAK; - } - - static { - // initialize the action table - for (int t0 = 0; t0 < 5; t0++) { - for (int t1 = 0; t1 < 5; t1++) { - actionTable[t0 * 5 + t1] = decideAction(t0, t1); - } - } - } - - /** - * Classify a character into 5 categories that determine the word break. - * - * @param ch - * the character - * @return the categorization - */ - protected static int classify(char ch) { - switch (Character.getType(ch)) { - case Character.UPPERCASE_LETTER: - return UPPER_LETTER; - case Character.LOWERCASE_LETTER: - return LOWER_LETTER; - case Character.TITLECASE_LETTER: - case Character.MODIFIER_LETTER: - case Character.OTHER_LETTER: - return OTHER_LETTER; - case Character.DECIMAL_DIGIT_NUMBER: - return DIGIT; - default: - return OTHER; - } - } - - /** - * Tokenizes a string into words and capitalizes the first character of each - * word. - *

- * This method uses a change in character type as a splitter of two words. For - * example, "abc100ghi" will be splitted into {"Abc", "100","Ghi"}. - * - * @param str - * the string to split into a word list - * @return the word list - */ - public static List toWordList(String str) { - ArrayList retval = new ArrayList<>(); - int len = str.length(); - for (int i = 0; i < len;) { - - // Skip punctuation - while (i < len) { - if (!isPunct(str.charAt(i))) { - break; - } - i++; - } - if (i >= len) { - break; - } - - // Find next break and collect word - int breakPos = nextBreak(str, i); - String word = (breakPos == -1) ? str.substring(i) : str.substring(i, breakPos); - retval.add(escape(capitalize(word))); - if (breakPos == -1) { - break; - } - i = breakPos; - } - - // we can't guarantee a valid Java identifier anyway, - // so there's not much point in rejecting things in this way. - // if (ss.size() == 0) - // throw new IllegalArgumentException("Zero-length identifier"); - return retval; - } - - protected static String toMixedCaseName(List ss, boolean startUpper) { - StringBuilder sb = new StringBuilder(); - if (!ss.isEmpty()) { - sb.append(startUpper ? ss.get(0) : ss.get(0).toLowerCase(Locale.ENGLISH)); - for (int i = 1; i < ss.size(); i++) { - sb.append(ss.get(i)); - } - } - return sb.toString(); - } - - protected static String toMixedCaseVariableName(String[] ss, - boolean startUpper, - boolean cdrUpper) { - if (cdrUpper) { - for (int i = 1; i < ss.length; i++) { - ss[i] = capitalize(ss[i]); - } - } - StringBuilder sb = new StringBuilder(); - if (ss.length > 0) { - sb.append(startUpper ? ss[0] : ss[0].toLowerCase(Locale.ENGLISH)); - for (int i = 1; i < ss.length; i++) { - sb.append(ss[i]); - } - } - return sb.toString(); - } - - /** - * Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF". - * - * @param str - * the string to format - * @return Always return a string but there's no guarantee that the generated - * code is a valid Java identifier. - */ - public String toConstantName(String str) { - return toConstantName(toWordList(str)); - } - - /** - * Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF". - * - * @param ss - * a list of words - * @return Always return a string but there's no guarantee that the generated - * code is a valid Java identifier. - */ - public String toConstantName(List ss) { - StringBuilder sb = new StringBuilder(); - if (!ss.isEmpty()) { - sb.append(ss.get(0).toUpperCase(Locale.ENGLISH)); - for (int i = 1; i < ss.size(); i++) { - sb.append('_'); - sb.append(ss.get(i).toUpperCase(Locale.ENGLISH)); - } - } - return sb.toString(); - } - - /** - * Escapes characters is the given string so that they can be printed by only - * using US-ASCII characters. - * - * The escaped characters will be appended to the given StringBuffer. - * - * @param sb - * StringBuffer that receives escaped string. - * @param str - * String to be escaped. s.substring(start) will be - * escaped and copied to the string buffer. - * @param start - * the starting position in the string - */ - @SuppressWarnings({ - "checkstyle:MissingSwitchDefaultCheck", // intentional - "checkstyle:AvoidEscapedUnicodeCharactersCheck" // ok - }) - public static void escape(StringBuilder sb, String str, int start) { - int len = str.length(); - for (int i = start; i < len; i++) { - char ch = str.charAt(i); - if (Character.isJavaIdentifierPart(ch)) { - sb.append(ch); - } else { - sb.append('_'); - if (ch <= '\u000f') { - sb.append("000"); - } else if (ch <= '\u00ff') { - sb.append("00"); - } else if (ch <= '\u0fff') { - sb.append('0'); - } - sb.append(Integer.toString(ch, 16)); - } - } - } - - /** - * Escapes characters that are unusable as Java identifiers by replacing unsafe - * characters with safe characters. - */ - private static String escape(String str) { - int len = str.length(); - for (int i = 0; i < len; i++) { - if (!Character.isJavaIdentifierPart(str.charAt(i))) { - StringBuilder sb = new StringBuilder(str.substring(0, i)); - escape(sb, str, i); - return sb.toString(); - } - } - return str; - } -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonReader.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonReader.java index 0d7f010ad..fd208175c 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonReader.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonReader.java @@ -278,7 +278,7 @@ public Object readItemField(Object parentItem, IBoundInstanceModelFieldComplex i parentItem, instance.getDefinition(), instance.getJsonProperties(), - instance.getJsonKey(), + instance.getEffectiveJsonKey(), getProblemHandler()); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonUtil.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonUtil.java index 0d9a3ff62..dae2222fe 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonUtil.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonUtil.java @@ -76,7 +76,7 @@ private MetaschemaJsonUtil() { Collection flags = targetDefinition.getFlagInstances(); int flagCount = flags.size() - (jsonKey == null ? 0 : 1); - @SuppressWarnings("resource") Stream instanceStream; + Stream instanceStream; if (targetDefinition instanceof IBoundDefinitionModelAssembly) { // use all child instances instanceStream = ((IBoundDefinitionModelAssembly) targetDefinition).getModelInstances().stream() @@ -100,7 +100,7 @@ private MetaschemaJsonUtil() { if (jsonKey != null) { instanceStream = Stream.concat( - flags.stream().filter((flag) -> !jsonKey.equals(flag)), + flags.stream().filter(flag -> !jsonKey.equals(flag)), instanceStream); } else { instanceStream = Stream.concat( diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundContainerFlag.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundContainerFlag.java deleted file mode 100644 index 72997386b..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundContainerFlag.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ - -package gov.nist.secauto.metaschema.databind.model; - -import gov.nist.secauto.metaschema.core.model.IModelDefinition; - -import java.util.Collection; - -import javax.xml.namespace.QName; - -public interface IBoundContainerFlag extends IModelDefinition { -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModel.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModel.java index 2afe9bf7b..59ca1ce3e 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModel.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModel.java @@ -27,7 +27,6 @@ package gov.nist.secauto.metaschema.databind.model; import gov.nist.secauto.metaschema.core.model.IModelDefinition; -import gov.nist.secauto.metaschema.databind.model.info.IItemValueHandler; import java.util.Collection; @@ -38,7 +37,7 @@ */ // REFACTOR: rename to IBoundDefinitionModel public interface IBoundDefinitionModel - extends IBoundDefinition, IModelDefinition, IItemValueHandler { + extends IBoundDefinition, IModelDefinition { @Override IBoundInstanceModelNamed getInlineInstance(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelField.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelField.java index 2208c2a7b..5ca749f86 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelField.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelField.java @@ -63,7 +63,7 @@ static IBoundInstanceModelField newInstance( IBoundInstanceModelField retval; if (definition == null) { - retval = new InstanceModelFieldScalar(field, containingDefinition); + retval = InstanceModelFieldScalar.newInstance(field, containingDefinition); } else if (definition instanceof DefinitionField) { retval = new InstanceModelFieldComplex(field, (DefinitionField) definition, containingDefinition); } else { diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelFieldComplex.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelFieldComplex.java index 4a83597f4..c2c7e0fb4 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelFieldComplex.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelFieldComplex.java @@ -33,10 +33,6 @@ import java.io.IOException; -import javax.xml.namespace.QName; - -import edu.umd.cs.findbugs.annotations.NonNull; - public interface IBoundInstanceModelFieldComplex extends IBoundInstanceModelField, IBoundInstanceModelNamedComplex { diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundAssembly.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundAssembly.java index a56ace9f1..24336d38b 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundAssembly.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundAssembly.java @@ -44,8 +44,7 @@ * Module assembly. *

* For XML serialization, the {@link #useName()} identifies the name of the - * element to use and the {@link #namespace()} identifies the namespace of this - * element. + * element to use for this element. *

* For JSON and YAML serializations, the {@link #useName()} identifies the * property/item name to use. diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundField.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundField.java index 26d43e7fa..a286fe730 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundField.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundField.java @@ -45,8 +45,7 @@ * Module field. *

* For XML serialization, the {@link #useName()} identifies the name of the - * element to use and the {@link #namespace()} identifies the namespace of this - * element. + * element to use for this element. *

* For JSON and YAML serializations, the {@link #useName()} identifies the * property/item name to use. diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedAssembly.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedAssembly.java index bb6ab878c..972c0cfca 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedAssembly.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedAssembly.java @@ -42,8 +42,7 @@ * Module assembly. *

* For XML serialization, the {@link #useName()} identifies the name of the - * element to use and the {@link #namespace()} identifies the namespace of this - * element. + * element to use for this element. *

* For JSON and YAML serializations, the {@link #useName()} identifies the * property/item name to use. diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedField.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedField.java index a337096a6..b66939dff 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedField.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundGroupedField.java @@ -43,8 +43,7 @@ * Module field. *

* For XML serialization, the {@link #useName()} identifies the name of the - * element to use and the {@link #namespace()} identifies the namespace of this - * element. + * element to use for this element. *

* For JSON and YAML serializations, the {@link #useName()} identifies the * property/item name to use. diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionAssembly.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionAssembly.java index 8cdcec222..6ae6a8e4c 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionAssembly.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionAssembly.java @@ -56,7 +56,7 @@ import nl.talsmasoftware.lazy4j.Lazy; //TODO: implement getProperties() -public class DefinitionAssembly +public final class DefinitionAssembly extends AbstractBoundDefinitionModelComplex implements IBoundDefinitionModelAssembly, IFeatureBoundContainerModelAssembly< diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionField.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionField.java index ed8dfb849..ebb54ca48 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionField.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/DefinitionField.java @@ -57,7 +57,7 @@ import nl.talsmasoftware.lazy4j.Lazy; //TODO: implement getProperties() -public class DefinitionField +public final class DefinitionField extends AbstractBoundDefinitionModelComplex implements IBoundDefinitionModelFieldComplex { @NonNull diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldScalar.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldScalar.java index e535c04e0..4bbb42b4d 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldScalar.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldScalar.java @@ -52,7 +52,7 @@ import edu.umd.cs.findbugs.annotations.Nullable; import nl.talsmasoftware.lazy4j.Lazy; -public class InstanceModelFieldScalar +public final class InstanceModelFieldScalar extends AbstractInlineFieldDefinition< IBoundDefinitionModelAssembly, IBoundDefinitionModelField, @@ -75,32 +75,22 @@ public class InstanceModelFieldScalar @NonNull private final Lazy constraints; - /** - * Construct a new field instance bound to a Java field. - * - * @param javaField - * the Java field bound to this instance - * @param containingDefinition - * the definition containing this instance - */ - public InstanceModelFieldScalar( + public static InstanceModelFieldScalar newInstance( @NonNull Field javaField, @NonNull IBoundDefinitionModelAssembly containingDefinition) { - super(containingDefinition); - this.javaField = javaField; - this.annotation = ModelUtil.getAnnotation(javaField, BoundField.class); - this.collectionInfo = ObjectUtils.notNull(Lazy.lazy(() -> IModelInstanceCollectionInfo.of(this))); - this.groupAs = ModelUtil.groupAs( - this.annotation.groupAs(), + BoundField annotation = ModelUtil.getAnnotation(javaField, BoundField.class); + IGroupAs groupAs = ModelUtil.groupAs( + annotation.groupAs(), containingDefinition.getContainingModule()); - if (getMaxOccurs() == -1 || getMaxOccurs() > 1) { - if (IGroupAs.SINGLETON_GROUP_AS.equals(this.groupAs)) { + + if (annotation.maxOccurs() == -1 || annotation.maxOccurs() > 1) { + if (IGroupAs.SINGLETON_GROUP_AS.equals(groupAs)) { throw new IllegalStateException(String.format("Field '%s' on class '%s' is missing the '%s' annotation.", javaField.getName(), javaField.getDeclaringClass().getName(), GroupAs.class.getName())); // NOPMD false positive } - } else if (!IGroupAs.SINGLETON_GROUP_AS.equals(this.groupAs)) { + } else if (!IGroupAs.SINGLETON_GROUP_AS.equals(groupAs)) { // max is 1 and a groupAs is set throw new IllegalStateException( String.format( @@ -110,14 +100,42 @@ public InstanceModelFieldScalar( GroupAs.class.getName())); // NOPMD false positive } + return new InstanceModelFieldScalar( + javaField, + annotation, + groupAs, + containingDefinition); + } + + /** + * Construct a new field instance bound to a Java field. + * + * @param javaField + * the Java field bound to this instance + * @param annotation + * the field binding annotation + * @param groupAs + * the grouping info for the model instance + * @param containingDefinition + * the definition containing this instance + */ + private InstanceModelFieldScalar( + @NonNull Field javaField, + @NonNull BoundField annotation, + @NonNull IGroupAs groupAs, + @NonNull IBoundDefinitionModelAssembly containingDefinition) { + super(containingDefinition); + this.javaField = javaField; + this.annotation = annotation; + this.collectionInfo = ObjectUtils.notNull(Lazy.lazy(() -> IModelInstanceCollectionInfo.of(this))); + this.groupAs = groupAs; this.javaTypeAdapter = ModelUtil.getDataTypeAdapter( - this.annotation.typeAdapter(), + annotation.typeAdapter(), containingDefinition.getBindingContext()); - this.defaultValue = ModelUtil.resolveDefaultValue(this.annotation.defaultValue(), this.javaTypeAdapter); - + this.defaultValue = ModelUtil.resolveDefaultValue(annotation.defaultValue(), this.javaTypeAdapter); this.constraints = ObjectUtils.notNull(Lazy.lazy(() -> { IValueConstrained retval = new ValueConstraintSet(); - ValueConstraints valueAnnotation = this.annotation.valueConstraints(); + ValueConstraints valueAnnotation = annotation.valueConstraints(); ConstraintSupport.parse(valueAnnotation, ISource.modelSource(), retval); return retval; })); @@ -197,12 +215,12 @@ public boolean isInXmlWrapped() { } @Override - public final int getMinOccurs() { + public int getMinOccurs() { return getAnnotation().minOccurs(); } @Override - public final int getMaxOccurs() { + public int getMaxOccurs() { return getAnnotation().maxOccurs(); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/AbstractModelInstanceReadHandler.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/AbstractModelInstanceReadHandler.java index bc39a0472..36b7e7b95 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/AbstractModelInstanceReadHandler.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/AbstractModelInstanceReadHandler.java @@ -66,6 +66,8 @@ public IModelInstanceCollectionInfo getCollectionInfo() { } /** + * Get the object onto which parsed data will be stored. + * * @return the parentObject */ @NonNull diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingConstraintLoader.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingConstraintLoader.java index ee3d1899f..57e1b8ae4 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingConstraintLoader.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingConstraintLoader.java @@ -57,6 +57,7 @@ import gov.nist.secauto.metaschema.databind.io.IBoundLoader; import gov.nist.secauto.metaschema.databind.model.metaschema.binding.MetapathContext; import gov.nist.secauto.metaschema.databind.model.metaschema.binding.MetaschemaMetaConstraints; +import gov.nist.secauto.metaschema.databind.model.metaschema.binding.MetaschemaMetapath; import gov.nist.secauto.metaschema.databind.model.metaschema.binding.MetaschemaModuleConstraints; import gov.nist.secauto.metaschema.databind.model.metaschema.impl.ConstraintBindingSupport; @@ -250,17 +251,15 @@ private Context parseContext( List metapaths; if (parent == null) { metapaths = CollectionUtil.listOrEmpty(contextObj.getMetapaths()).stream() - .map(metapath -> metapath.getTarget()) + .map(MetaschemaMetapath::getTarget) .collect(Collectors.toList()); } else { List parentMetapaths = parent.getMetapaths().stream() .collect(Collectors.toList()); metapaths = CollectionUtil.listOrEmpty(contextObj.getMetapaths()).stream() - .map(metapath -> metapath.getTarget()) - .flatMap(childPath -> { - return parentMetapaths.stream() - .map(parentPath -> parentPath + '/' + childPath); - }) + .map(MetaschemaMetapath::getTarget) + .flatMap(childPath -> parentMetapaths.stream() + .map(parentPath -> parentPath + '/' + childPath)) .collect(Collectors.toList()); } @@ -281,8 +280,6 @@ private static class Context { @NonNull private final List metapaths; @NonNull - private final IModelConstrained constraints; - @NonNull private final List childContexts = new LinkedList<>(); @NonNull private final Lazy> targetedConstraints; @@ -291,7 +288,6 @@ public Context( @NonNull List metapaths, @NonNull IModelConstrained constraints) { this.metapaths = metapaths; - this.constraints = constraints; this.targetedConstraints = ObjectUtils.notNull(Lazy.lazy(() -> { Stream paths = getMetapaths().stream() diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionFieldGlobal.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionFieldGlobal.java index baf70d986..308b2c0af 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionFieldGlobal.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionFieldGlobal.java @@ -187,7 +187,6 @@ public String getJsonValueKeyName() { return getBinding().getJsonValueKey(); } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java index ba63f1794..0a359ecbb 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java @@ -105,7 +105,6 @@ public IValueConstrained getConstraintSupport() { return valueConstraints.get(); } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyInline.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyInline.java index 1b13b7079..b1c458897 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyInline.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyInline.java @@ -169,7 +169,6 @@ public IGroupAs getGroupAs() { return groupAs; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyReference.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyReference.java index 20e0f8318..47b18d51f 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyReference.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyReference.java @@ -117,7 +117,6 @@ public IGroupAs getGroupAs() { return groupAs; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java index 6fc1feaed..1c17ec0d9 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java @@ -95,7 +95,6 @@ IAssemblyInstanceAbsolute> getModelContainer() { return ObjectUtils.notNull(modelContainer.get()); } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java index 0a4a21097..55f7bef50 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java @@ -106,7 +106,6 @@ public IGroupAs getGroupAs() { return groupAs; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldInline.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldInline.java index aa1b5c2da..f14a7f4ae 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldInline.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldInline.java @@ -136,7 +136,6 @@ public IGroupAs getGroupAs() { return groupAs; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldReference.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldReference.java index b19e8c055..5ee14088d 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldReference.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldReference.java @@ -107,7 +107,6 @@ public IGroupAs getGroupAs() { return groupAs; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyInline.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyInline.java index e9e99909d..613ec15c3 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyInline.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyInline.java @@ -158,7 +158,6 @@ public IModelConstrained getConstraintSupport() { return ObjectUtils.notNull(modelConstraints.get()); } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyReference.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyReference.java index cb9323584..8aff406bd 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyReference.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedAssemblyReference.java @@ -91,7 +91,6 @@ public Map> getProperties() { return properties; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldInline.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldInline.java index 6d584af49..2e55eef45 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldInline.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldInline.java @@ -131,7 +131,6 @@ public IValueConstrained getConstraintSupport() { return ObjectUtils.notNull(valueConstraints.get()); } - @SuppressWarnings("null") @Override public IFieldNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldReference.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldReference.java index eccc156fc..35d1ea4c5 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldReference.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelGroupedFieldReference.java @@ -92,7 +92,6 @@ public Map> getProperties() { return properties; } - @SuppressWarnings("null") @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get();