From d6296b2076fc7b8a6b83605d783ebccf9c783d49 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Sat, 9 Nov 2024 00:12:05 -0500 Subject: [PATCH] Code reformatting. --- core/metaschema | 2 +- .../core/datatype/DataTypeService.java | 3 +- .../core/datatype/adapter/DateAdapter.java | 10 +-- .../datatype/adapter/DateTimeAdapter.java | 6 +- .../datatype/adapter/EmailAddressAdapter.java | 3 +- .../datatype/adapter/HostnameAdapter.java | 3 +- .../core/datatype/adapter/IntegerAdapter.java | 3 +- .../core/datatype/adapter/StringAdapter.java | 3 +- .../datatype/markup/MarkupLineAdapter.java | 3 +- .../markup/MarkupMultilineAdapter.java | 3 +- .../flexmark/HtmlCodeRenderExtension.java | 3 +- .../flexmark/HtmlQuoteTagExtension.java | 3 +- .../flexmark/InsertAnchorExtension.java | 3 +- .../flexmark/SuppressPTagExtension.java | 3 +- .../metapath/cst/AbstractCSTVisitorBase.java | 6 +- .../core/metapath/cst/BuildCSTVisitor.java | 6 +- .../core/metapath/cst/ExpressionUtils.java | 9 ++- .../metapath/cst/PredicateExpression.java | 6 +- .../core/metapath/cst/StaticFunctionCall.java | 3 +- .../metaschema/core/metapath/cst/Union.java | 3 +- .../cst/path/AbstractPathExpression.java | 3 +- .../path/AbstractRelativePathExpression.java | 3 +- .../metapath/format/MetapathFormatter.java | 3 +- .../function/ComparisonFunctions.java | 3 +- .../metapath/function/DefaultFunction.java | 3 +- .../metapath/function/OperationFunctions.java | 63 ++++++++++++------- .../function/library/ArrayAppend.java | 3 +- .../function/library/ArrayInsertBefore.java | 3 +- .../metapath/function/library/ArrayPut.java | 3 +- .../metapath/function/library/MapEntry.java | 3 +- .../metapath/function/library/MapMerge.java | 3 +- .../metapath/function/library/MapPut.java | 6 +- .../function/library/MpRecurseDepth.java | 3 +- .../core/metapath/impl/StreamSequence.java | 3 +- .../core/metapath/item/TypeSystem.java | 3 +- .../metapath/item/atomic/IIntegerItem.java | 6 +- .../metapath/item/atomic/INumericItem.java | 3 +- .../item/node/AbstractNodeItemFactory.java | 6 +- .../metapath/item/node/IFieldNodeItem.java | 3 +- .../metapath/item/node/IFlagNodeItem.java | 9 ++- .../core/model/AbstractModuleLoader.java | 3 +- .../metaschema/core/model/IGroupable.java | 3 +- .../secauto/metaschema/core/model/INamed.java | 6 +- .../model/INamedModelInstanceAbsolute.java | 6 +- .../DefaultConstraintValidator.java | 3 +- .../core/model/util/XmlEventUtil.java | 9 ++- .../datatype/markup/MarkupStringTest.java | 3 +- .../core/metapath/ExpressionUtilsTest.java | 9 ++- .../core/metapath/cst/FlagTest.java | 3 +- .../metapath/cst/PredicateExpressionTest.java | 18 ++++-- .../modules/sarif/SarifValidationHandler.java | 3 +- .../metaschema/databind/IBindingContext.java | 3 +- .../config/DefaultBindingConfiguration.java | 3 +- .../AbstractModelInstanceTypeInfo.java | 6 +- .../AbstractNamedModelInstanceTypeInfo.java | 3 +- .../codegen/typeinfo/DefaultTypeResolver.java | 3 +- .../io/json/MetaschemaJsonReader.java | 12 ++-- .../io/json/MetaschemaJsonWriter.java | 3 +- .../annotations/NullJavaTypeAdapter.java | 6 +- .../info/IFeatureComplexItemValueHandler.java | 6 +- .../model/info/SingletonCollectionInfo.java | 3 +- .../metaschema/BindingConstraintLoader.java | 3 +- .../binding/MetaschemaModelModule.java | 3 +- .../codegen/AbstractMetaschemaTest.java | 3 +- .../databind/codegen/BasicMetaschemaTest.java | 9 ++- .../maven/plugin/GenerateSchemaMojo.java | 3 +- .../schemagen/AbstractSchemaGenerator.java | 3 +- .../schemagen/json/JsonSchemaGenerator.java | 3 +- .../impl/AssemblyDefinitionJsonSchema.java | 3 +- .../json/impl/JsonGenerationState.java | 3 +- .../xml/impl/DocumentationGenerator.java | 12 ++-- .../impl/XmlProseBaseDatatypeProvider.java | 3 +- .../XmlProseCompositDatatypeProvider.java | 4 +- .../AbstractSchemaGeneratorTestSuite.java | 9 ++- 74 files changed, 261 insertions(+), 133 deletions(-) diff --git a/core/metaschema b/core/metaschema index 20c107794..b6601f743 160000 --- a/core/metaschema +++ b/core/metaschema @@ -1 +1 @@ -Subproject commit 20c107794327ff3c2cc39ce98f462c8c0791d916 +Subproject commit b6601f7430f83f1a53a11bf32575b69e131bc912 diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java index 4b4f60778..264b4d62b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/DataTypeService.java @@ -90,7 +90,8 @@ private DataTypeService() { }, ConcurrentHashMap::new)); - @SuppressWarnings({ "unchecked", "null" }) Map>, + @SuppressWarnings({ "unchecked", "null" }) + Map>, IDataTypeAdapter> typeByClass = dataTypes.stream() .collect(CustomCollectors.toMap( dataType -> (Class>) dataType.getClass(), diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java index eedbbe322..d8191f8be 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateAdapter.java @@ -90,11 +90,13 @@ public String asString(Object obj) { String retval; if (value.hasTimeZone()) { @SuppressWarnings("null") - @NonNull String formatted = DateFormats.DATE_WITH_TZ.format(value.getValue()); + @NonNull + String formatted = DateFormats.DATE_WITH_TZ.format(value.getValue()); retval = formatted; } else { @SuppressWarnings("null") - @NonNull String formatted = DateFormats.DATE_WITHOUT_TZ.format(value.getValue()); + @NonNull + String formatted = DateFormats.DATE_WITHOUT_TZ.format(value.getValue()); retval = formatted; } return retval; @@ -112,7 +114,8 @@ public IDateItem newItem(Object value) { } @Override - protected @NonNull IDateItem castInternal(@NonNull IAnyAtomicItem item) { + @NonNull + protected IDateItem castInternal(@NonNull IAnyAtomicItem item) { IDateItem retval; if (item instanceof IDateTimeItem) { ZonedDateTime value = ((IDateTimeItem) item).asZonedDateTime(); @@ -125,5 +128,4 @@ public IDateItem newItem(Object value) { } return retval; } - } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java index 91d82a2e4..32cb0b385 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/DateTimeAdapter.java @@ -74,11 +74,13 @@ public String asString(Object obj) { String retval; if (value.hasTimeZone()) { @SuppressWarnings("null") - @NonNull String formatted = DateFormats.DATE_TIME_WITH_TZ.format(value.getValue()); + @NonNull + String formatted = DateFormats.DATE_TIME_WITH_TZ.format(value.getValue()); retval = formatted; } else { @SuppressWarnings("null") - @NonNull String formatted = DateFormats.DATE_TIME_WITHOUT_TZ.format(value.getValue()); + @NonNull + String formatted = DateFormats.DATE_TIME_WITHOUT_TZ.format(value.getValue()); retval = formatted; } return retval; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/EmailAddressAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/EmailAddressAdapter.java index 797776007..982325aec 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/EmailAddressAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/EmailAddressAdapter.java @@ -34,7 +34,8 @@ public List getNames() { } @Override - public @NonNull Class getItemClass() { + @NonNull + public Class getItemClass() { return IEmailAddressItem.class; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/HostnameAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/HostnameAdapter.java index d5887bacc..51feb78d7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/HostnameAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/HostnameAdapter.java @@ -31,7 +31,8 @@ public List getNames() { } @Override - public @NonNull Class getItemClass() { + public @NonNull + Class getItemClass() { return IHostnameItem.class; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IntegerAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IntegerAdapter.java index 449598042..f77e74630 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IntegerAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/IntegerAdapter.java @@ -35,7 +35,8 @@ public List getNames() { } @Override - public @NonNull Class getItemClass() { + @NonNull + public Class getItemClass() { return IIntegerItem.class; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/StringAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/StringAdapter.java index 4d1118b7e..18b0e4d05 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/StringAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/adapter/StringAdapter.java @@ -36,7 +36,8 @@ public Class getItemClass() { } @Override - public @NonNull IStringItem newItem(@NonNull Object value) { + @NonNull + public IStringItem newItem(@NonNull Object value) { String item = asString(value); return IStringItem.valueOf(item); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java index 56dce9958..314d42654 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupLineAdapter.java @@ -57,7 +57,8 @@ public MarkupLine parse(XMLEventReader2 eventReader) throws IOException { @Override public MarkupLine parse(JsonParser parser) throws IOException { - @SuppressWarnings("null") MarkupLine retval = parse(parser.getValueAsString()); + @SuppressWarnings("null") + MarkupLine retval = parse(parser.getValueAsString()); // skip past value parser.nextToken(); return retval; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java index f62466284..62e432c88 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultilineAdapter.java @@ -62,7 +62,8 @@ public MarkupMultiline parse(XMLEventReader2 eventReader) throws IOException { @Override public MarkupMultiline parse(JsonParser parser) throws IOException { - @SuppressWarnings("null") MarkupMultiline retval = parse(parser.getValueAsString()); + @SuppressWarnings("null") + MarkupMultiline retval = parse(parser.getValueAsString()); // skip past value parser.nextToken(); return retval; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlCodeRenderExtension.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlCodeRenderExtension.java index 8ec9fe215..ae356bc38 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlCodeRenderExtension.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlCodeRenderExtension.java @@ -63,7 +63,8 @@ private CodeNodeHtmlRenderer(DataHolder options) { } @Override - public @Nullable Set> getNodeRenderingHandlers() { + @Nullable + public Set> getNodeRenderingHandlers() { return Collections.singleton( new NodeRenderingHandler<>(Code.class, this::render)); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlQuoteTagExtension.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlQuoteTagExtension.java index f3914a020..bba9165b8 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlQuoteTagExtension.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlQuoteTagExtension.java @@ -77,7 +77,8 @@ public void extend(FlexmarkHtmlConverter.Builder builder) { static class QTagNodeRenderer implements NodeRenderer { @Override - public @Nullable Set> getNodeRenderingHandlers() { + public @Nullable + Set> getNodeRenderingHandlers() { return Collections.singleton( new NodeRenderingHandler<>(DoubleQuoteNode.class, this::render)); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/InsertAnchorExtension.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/InsertAnchorExtension.java index bfd27a40f..cf12d9c35 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/InsertAnchorExtension.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/InsertAnchorExtension.java @@ -343,7 +343,8 @@ public void setIdReference(@NonNull BasedSequence idReference) { @Override @NonNull public BasedSequence[] getSegments() { - @NonNull BasedSequence[] retval = { getType(), getIdReference() }; + @NonNull + BasedSequence[] retval = { getType(), getIdReference() }; return retval; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/SuppressPTagExtension.java b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/SuppressPTagExtension.java index 309475266..683c75720 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/SuppressPTagExtension.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/SuppressPTagExtension.java @@ -46,7 +46,8 @@ public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) { static class PTagNodeRenderer implements NodeRenderer { @Override - public @Nullable Set> getNodeRenderingHandlers() { + public @Nullable + Set> getNodeRenderingHandlers() { return Collections.singleton( new NodeRenderingHandler<>(Paragraph.class, this::render)); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java index 00ea31537..a4a9e0546 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/AbstractCSTVisitorBase.java @@ -186,7 +186,8 @@ R nairyToCollection( // skip operator, since we know what it is ParseTree tree = ctx.getChild(idx + 1); @SuppressWarnings({ "unchecked", "null" }) - @NonNull NODE node = (NODE) tree.accept(this); + @NonNull + NODE node = (NODE) tree.accept(this); return node; }, supplier); } @@ -238,7 +239,8 @@ R nairyToCollection( ParseTree leftTree = context.getChild(0); @SuppressWarnings({ "unchecked", "null" }) - @NonNull EXPRESSION leftResult = (EXPRESSION) leftTree.accept(this); + @NonNull + EXPRESSION leftResult = (EXPRESSION) leftTree.accept(this); IExpression retval; if (numChildren == 1) { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java index 3fdbcc0f3..ad7a9bc59 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java @@ -207,7 +207,8 @@ protected IExpression handleForexpr(ForexprContext ctx) { // for SimpleForBinding ("," SimpleForBinding)* int bindingCount = simpleForClause.getChildCount() / 2; - @NonNull IExpression retval = ObjectUtils.notNull(ctx.exprsingle().accept(this)); + @NonNull + IExpression retval = ObjectUtils.notNull(ctx.exprsingle().accept(this)); // step through in reverse for (int idx = bindingCount - 1; idx >= 0; idx--) { @@ -236,7 +237,8 @@ protected IExpression handleForexpr(ForexprContext ctx) { @Override protected IExpression handleLet(LetexprContext context) { - @NonNull IExpression retval = ObjectUtils.notNull(context.exprsingle().accept(this)); + @NonNull + IExpression retval = ObjectUtils.notNull(context.exprsingle().accept(this)); SimpleletclauseContext letClause = context.simpleletclause(); List clauses = letClause.simpleletbinding(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ExpressionUtils.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ExpressionUtils.java index 44d79d127..5a68d1146 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ExpressionUtils.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ExpressionUtils.java @@ -58,12 +58,14 @@ private static Class findCommonBase( @NonNull List> expressionClasses) { Class retval; if (expressionClasses.size() == 1) { - @SuppressWarnings("unchecked") Class result + @SuppressWarnings("unchecked") + Class result = (Class) expressionClasses.iterator().next(); assert result != null; retval = result; } else { - @SuppressWarnings("unchecked") Class first + @SuppressWarnings("unchecked") + Class first = (Class) expressionClasses.iterator().next(); assert first != null; if (baseType.equals(first)) { @@ -75,7 +77,8 @@ private static Class findCommonBase( baseType, first, ObjectUtils.notNull(expressionClasses.subList(1, expressionClasses.size()))); - @SuppressWarnings("unchecked") Class newBase + @SuppressWarnings("unchecked") + Class newBase = (Class) leastCommon; if (newBase != null) { retval = newBase; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpression.java index c53c774ac..001911ba7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpression.java @@ -68,7 +68,8 @@ public List getChildren() { } @Override - public @NonNull ISequence accept(@NonNull DynamicContext dynamicContext, + public @NonNull + ISequence accept(@NonNull DynamicContext dynamicContext, @NonNull ISequence focus) { ISequence retval = getBase().accept(dynamicContext, focus); @@ -83,7 +84,8 @@ public List getChildren() { return Map.entry(BigInteger.valueOf(index.incrementAndGet()), item); }).filter(entry -> { @SuppressWarnings("null") - @NonNull IItem item = entry.getValue(); + @NonNull + IItem item = entry.getValue(); // return false if any predicate evaluates to false return !predicates.stream() diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java index 3fdce9780..2c52db86e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/StaticFunctionCall.java @@ -82,7 +82,8 @@ public RESULT accept(IExpressionVisitor visit @Override public ISequence accept(DynamicContext dynamicContext, ISequence focus) { List> arguments = ObjectUtils.notNull(getChildren().stream().map(expression -> { - @NonNull ISequence result = expression.accept(dynamicContext, focus); + @NonNull + ISequence result = expression.accept(dynamicContext, focus); return result; }).collect(Collectors.toList())); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Union.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Union.java index f79dcb6af..b2f3ad708 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Union.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/Union.java @@ -53,7 +53,8 @@ public ISequence accept(DynamicContext dynamicContext, ISequence focus) { focus.getValue(); // now process the union - @NonNull Stream retval = ObjectUtils.notNull(getChildren().stream() + @NonNull + Stream retval = ObjectUtils.notNull(getChildren().stream() .flatMap(child -> { ISequence result = child.accept(dynamicContext, focus); return result.stream(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java index edbe32f93..aef36aea9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java @@ -52,7 +52,8 @@ protected Stream searchExpression( outerFocus.getValue(); // check the current focus - @SuppressWarnings("unchecked") Stream nodeMatches + @SuppressWarnings("unchecked") + Stream nodeMatches = (Stream) expression.accept(dynamicContext, outerFocus).stream(); Stream childMatches = outerFocus.stream() diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractRelativePathExpression.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractRelativePathExpression.java index fca9fb5d0..a89bb585d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractRelativePathExpression.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractRelativePathExpression.java @@ -64,7 +64,8 @@ public List getChildren() { } @Override - public final @NonNull Class getBaseResultType() { + public final @NonNull + Class getBaseResultType() { return INodeItem.class; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/MetapathFormatter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/MetapathFormatter.java index 78dd71d8b..94436d99c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/MetapathFormatter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/MetapathFormatter.java @@ -25,7 +25,8 @@ public class MetapathFormatter implements IPathFormatter { @Override - public @NonNull String formatMetaschema(IModuleNodeItem metaschema) { + public @NonNull + String formatMetaschema(IModuleNodeItem metaschema) { // this will result in a slash being generated using the join in the format // method return ""; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java index 8607476e3..aab9f3737 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/ComparisonFunctions.java @@ -172,7 +172,8 @@ public static IBooleanItem compare( // NOPMD - unavoidable @NonNull IAnyAtomicItem left, @NonNull Operator operator, @NonNull IAnyAtomicItem right) { - @NonNull IBooleanItem retval; + @NonNull + IBooleanItem retval; if (left instanceof IStringItem || right instanceof IStringItem) { retval = stringCompare(IStringItem.cast(left), operator, IStringItem.cast(right)); } else if (left instanceof INumericItem && right instanceof INumericItem) { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java index b8e7f2c4f..40752c640 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/DefaultFunction.java @@ -95,7 +95,8 @@ public ISequenceType getResult() { public static List> convertArguments( @NonNull IFunction function, @NonNull List> parameters) { - @NonNull List> retval = new ArrayList<>(parameters.size()); + @NonNull + List> retval = new ArrayList<>(parameters.size()); Iterator argumentIterator = function.getArguments().iterator(); IArgument argument = null; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java index 23e4baba3..dac656c15 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/OperationFunctions.java @@ -241,7 +241,8 @@ private static IDateItem subtractDurationFromDate( @NonNull ZonedDateTime dateTime, @NonNull TemporalAmount duration) { @SuppressWarnings("null") - @NonNull ZonedDateTime result = dateTime.minus(duration); + @NonNull + ZonedDateTime result = dateTime.minus(duration); return IDateItem.valueOf(result); } @@ -263,7 +264,8 @@ public static IYearMonthDurationItem opSubtractYearMonthDurations( Period duration2 = arg2.asPeriod(); @SuppressWarnings("null") - @NonNull Period duration = duration1.minus(duration2); + @NonNull + Period duration = duration1.minus(duration2); return IYearMonthDurationItem.valueOf(duration); } @@ -285,7 +287,8 @@ public static IDayTimeDurationItem opSubtractDayTimeDurations( Duration duration2 = arg2.asDuration(); @SuppressWarnings("null") - @NonNull Duration duration = duration1.minus(duration2); + @NonNull + Duration duration = duration1.minus(duration2); return IDayTimeDurationItem.valueOf(duration); } @@ -317,7 +320,8 @@ public static IDayTimeDurationItem opSubtractDateTimes(@NonNull IDateTimeItem ti @NonNull private static IDayTimeDurationItem between(@NonNull ZonedDateTime time1, @NonNull ZonedDateTime time2) { @SuppressWarnings("null") - @NonNull Duration between = Duration.between(time1, time2); + @NonNull + Duration between = Duration.between(time1, time2); return IDayTimeDurationItem.valueOf(between); } @@ -336,7 +340,8 @@ public static IDateTimeItem opSubtractYearMonthDurationFromDateTime( @NonNull IDateTimeItem moment, @NonNull IYearMonthDurationItem duration) { @SuppressWarnings("null") - @NonNull ZonedDateTime dateTime = moment.asZonedDateTime().minus(duration.asPeriod()); + @NonNull + ZonedDateTime dateTime = moment.asZonedDateTime().minus(duration.asPeriod()); return IDateTimeItem.valueOf(dateTime); } @@ -356,7 +361,8 @@ public static IDateTimeItem opSubtractDayTimeDurationFromDateTime( @NonNull IDayTimeDurationItem duration) { @SuppressWarnings("null") - @NonNull ZonedDateTime dateTime = moment.asZonedDateTime().plus(duration.asDuration()); + @NonNull + ZonedDateTime dateTime = moment.asZonedDateTime().plus(duration.asDuration()); return IDateTimeItem.valueOf(dateTime); } @@ -383,7 +389,8 @@ public static IYearMonthDurationItem opMultiplyYearMonthDuration( } @SuppressWarnings("null") - @NonNull Period period = arg1.asPeriod().multipliedBy(arg2Int); + @NonNull + Period period = arg1.asPeriod().multipliedBy(arg2Int); return IYearMonthDurationItem.valueOf(period); } @@ -409,7 +416,8 @@ public static IDayTimeDurationItem opMultiplyDayTimeDuration( } @SuppressWarnings("null") - @NonNull Duration duration = arg1.asDuration().multipliedBy(arg2Long); + @NonNull + Duration duration = arg1.asDuration().multipliedBy(arg2Long); return IDayTimeDurationItem.valueOf(duration); } @@ -457,7 +465,8 @@ public static IDayTimeDurationItem opDivideDayTimeDuration( @NonNull INumericItem arg2) { try { @SuppressWarnings("null") - @NonNull Duration duration = arg1.asDuration().dividedBy(FunctionUtils.asLong(arg2.round())); + @NonNull + Duration duration = arg1.asDuration().dividedBy(FunctionUtils.asLong(arg2.round())); return IDayTimeDurationItem.valueOf(duration); } catch (ArithmeticException ex) { throw new ArithmeticFunctionException(ArithmeticFunctionException.DIVISION_BY_ZERO, "Division by zero", ex); @@ -751,7 +760,8 @@ public static INumericItem opNumericAdd(@NonNull INumericItem left, @NonNull INu BigInteger integerRight = right.asInteger(); @SuppressWarnings("null") - @NonNull BigInteger result = integerLeft.add(integerRight); + @NonNull + BigInteger result = integerLeft.add(integerRight); retval = IIntegerItem.valueOf(result); } else { // create a decimal result @@ -759,7 +769,8 @@ public static INumericItem opNumericAdd(@NonNull INumericItem left, @NonNull INu BigDecimal decimalRight = right.asDecimal(); @SuppressWarnings("null") - @NonNull BigDecimal result = decimalLeft.add(decimalRight, FunctionUtils.MATH_CONTEXT); + @NonNull + BigDecimal result = decimalLeft.add(decimalRight, FunctionUtils.MATH_CONTEXT); retval = IDecimalItem.valueOf(result); } return retval; @@ -784,7 +795,8 @@ public static INumericItem opNumericSubtract(@NonNull INumericItem left, @NonNul BigInteger integerRight = right.asInteger(); @SuppressWarnings("null") - @NonNull BigInteger result = integerLeft.subtract(integerRight); + @NonNull + BigInteger result = integerLeft.subtract(integerRight); retval = IIntegerItem.valueOf(result); } else { // create a decimal result @@ -792,7 +804,8 @@ public static INumericItem opNumericSubtract(@NonNull INumericItem left, @NonNul BigDecimal decimalRight = right.asDecimal(); @SuppressWarnings("null") - @NonNull BigDecimal result = decimalLeft.subtract(decimalRight, FunctionUtils.MATH_CONTEXT); + @NonNull + BigDecimal result = decimalLeft.subtract(decimalRight, FunctionUtils.MATH_CONTEXT); retval = IDecimalItem.valueOf(result); } return retval; @@ -814,7 +827,8 @@ public static INumericItem opNumericMultiply(@NonNull INumericItem left, @NonNul if (left instanceof IIntegerItem || right instanceof IIntegerItem) { // create an integer result @SuppressWarnings("null") - @NonNull BigInteger result = left.asInteger().multiply(right.asInteger()); + @NonNull + BigInteger result = left.asInteger().multiply(right.asInteger()); retval = IIntegerItem.valueOf(result); } else { // create a decimal result @@ -822,7 +836,8 @@ public static INumericItem opNumericMultiply(@NonNull INumericItem left, @NonNul BigDecimal decimalRight = right.asDecimal(); @SuppressWarnings("null") - @NonNull BigDecimal result = decimalLeft.multiply(decimalRight, FunctionUtils.MATH_CONTEXT); + @NonNull + BigDecimal result = decimalLeft.multiply(decimalRight, FunctionUtils.MATH_CONTEXT); retval = IDecimalItem.valueOf(result); } return retval; @@ -851,7 +866,8 @@ public static IDecimalItem opNumericDivide(@NonNull INumericItem dividend, @NonN BigDecimal decimalDividend = dividend.asDecimal(); @SuppressWarnings("null") - @NonNull BigDecimal result = decimalDividend.divide(decimalDivisor, FunctionUtils.MATH_CONTEXT); + @NonNull + BigDecimal result = decimalDividend.divide(decimalDivisor, FunctionUtils.MATH_CONTEXT); return IDecimalItem.valueOf(result); } @@ -878,7 +894,8 @@ public static IIntegerItem opNumericIntegerDivide(@NonNull INumericItem dividend } @SuppressWarnings("null") - @NonNull BigInteger result = dividend.asInteger().divide(integerDivisor); + @NonNull + BigInteger result = dividend.asInteger().divide(integerDivisor); retval = IIntegerItem.valueOf(result); } else { // create a decimal result @@ -892,7 +909,8 @@ public static IIntegerItem opNumericIntegerDivide(@NonNull INumericItem dividend BigDecimal decimalDividend = dividend.asDecimal(); @SuppressWarnings("null") - @NonNull BigInteger result + @NonNull + BigInteger result = decimalDividend.divideToIntegralValue(decimalDivisor, FunctionUtils.MATH_CONTEXT).toBigInteger(); retval = IIntegerItem.valueOf(result); } @@ -925,7 +943,8 @@ public static INumericItem opNumericMod(@NonNull INumericItem dividend, @NonNull retval = dividend; } else { @SuppressWarnings("null") - @NonNull BigDecimal result = decimalDividend.remainder(decimalDivisor, FunctionUtils.MATH_CONTEXT); + @NonNull + BigDecimal result = decimalDividend.remainder(decimalDivisor, FunctionUtils.MATH_CONTEXT); retval = IDecimalItem.valueOf(result); } return retval; @@ -947,14 +966,16 @@ public static INumericItem opNumericUnaryMinus(@NonNull INumericItem item) { BigInteger integer = item.asInteger(); @SuppressWarnings("null") - @NonNull BigInteger result = integer.negate(); + @NonNull + BigInteger result = integer.negate(); retval = IIntegerItem.valueOf(result); } else if (item instanceof IDecimalItem) { // create a decimal result BigDecimal decimal = item.asDecimal(); @SuppressWarnings("null") - @NonNull BigDecimal result = decimal.negate(FunctionUtils.MATH_CONTEXT); + @NonNull + BigDecimal result = decimal.negate(FunctionUtils.MATH_CONTEXT); retval = IDecimalItem.valueOf(result); } else { throw new InvalidTypeMetapathException(item); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java index caeaa40a9..5b44d6cff 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayAppend.java @@ -62,7 +62,8 @@ private static ISequence> execute(@No IItem focus) { IArrayItem array = FunctionUtils.asType(ObjectUtils.requireNonNull( arguments.get(0).getFirstItem(true))); - @SuppressWarnings("unchecked") T appendage = (T) arguments.get(1).toCollectionValue(); + @SuppressWarnings("unchecked") + T appendage = (T) arguments.get(1).toCollectionValue(); return ISequence.of(append(array, appendage)); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java index 1a480be4d..5df8c77de 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayInsertBefore.java @@ -72,7 +72,8 @@ private static ISequence> execute(@No IArrayItem array = FunctionUtils.asType(ObjectUtils.requireNonNull( arguments.get(0).getFirstItem(true))); IIntegerItem position = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true))); - @SuppressWarnings("unchecked") T member = (T) ObjectUtils.requireNonNull(arguments.get(2)).toCollectionValue(); + @SuppressWarnings("unchecked") + T member = (T) ObjectUtils.requireNonNull(arguments.get(2)).toCollectionValue(); return ISequence.of(insertBefore(array, position, member)); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java index a1e9c6928..bc3769a77 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/ArrayPut.java @@ -73,7 +73,8 @@ private static ISequence> e IArrayItem array = FunctionUtils.asType(ObjectUtils.requireNonNull( arguments.get(0).getFirstItem(true))); IIntegerItem position = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true))); - @SuppressWarnings("unchecked") T member = (T) arguments.get(2).toCollectionValue(); + @SuppressWarnings("unchecked") + T member = (T) arguments.get(2).toCollectionValue(); return put(array, position, member).asSequence(); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java index 24be1823b..6d0c41d9b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapEntry.java @@ -61,7 +61,8 @@ private static ISequence> execute(@NonN @NonNull DynamicContext dynamicContext, IItem focus) { IAnyAtomicItem key = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(0).getFirstItem(true))); - @SuppressWarnings("unchecked") T value = (T) arguments.get(1).toCollectionValue(); + @SuppressWarnings("unchecked") + T value = (T) arguments.get(1).toCollectionValue(); return entry(key, value).asSequence(); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java index 34d94f22c..593adc7e3 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapMerge.java @@ -106,7 +106,8 @@ private enum Duplicates { private final CustomCollectors.DuplicateHandler duplicateHander; static { - @SuppressWarnings("PMD.UseConcurrentHashMap") Map map = new HashMap<>(); + @SuppressWarnings("PMD.UseConcurrentHashMap") + Map map = new HashMap<>(); for (Duplicates value : values()) { map.put(value.getName(), value); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java index 61b4945c4..eb6dbef22 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MapPut.java @@ -70,7 +70,8 @@ private static ISequence execute(@NonNull IFunct IItem focus) { IMapItem map = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(0).getFirstItem(true))); IAnyAtomicItem key = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true))); - @SuppressWarnings("unchecked") V value = (V) ObjectUtils.requireNonNull(arguments.get(2)).toCollectionValue(); + @SuppressWarnings("unchecked") + V value = (V) ObjectUtils.requireNonNull(arguments.get(2)).toCollectionValue(); return put(map, key, value).asSequence(); } @@ -94,7 +95,8 @@ public static IMapItem put( @NonNull IMapItem map, @NonNull IAnyAtomicItem key, @NonNull V value) { - @SuppressWarnings("PMD.UseConcurrentHashMap") Map copy = new HashMap<>(map); + @SuppressWarnings("PMD.UseConcurrentHashMap") + Map copy = new HashMap<>(map); copy.put(key.asMapKey(), value); return IMapItem.ofCollection(copy); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java index 06c8cb51d..a4791858b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/library/MpRecurseDepth.java @@ -143,7 +143,8 @@ public static ISequence recurseDepth( return ISequence.of(ObjectUtils.notNull(initialContext.stream() .flatMap(item -> { - @NonNull ISequence metapathResult = recursionMetapath.evaluate(item, dynamicContext); + @NonNull + ISequence metapathResult = recursionMetapath.evaluate(item, dynamicContext); // ensure this is list backed metapathResult.getValue(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/StreamSequence.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/StreamSequence.java index bfedaea5b..b5654339a 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/StreamSequence.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/impl/StreamSequence.java @@ -72,7 +72,8 @@ public List getValue() { @Override public Stream stream() { - @NonNull Stream retval; + @NonNull + Stream retval; // Ensure thread safety and prevent multiple consumptions of the stream instanceLock.lock(); try { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/TypeSystem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/TypeSystem.java index ca2fc2e59..d8017e3d2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/TypeSystem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/TypeSystem.java @@ -105,7 +105,8 @@ private static Map.Entry, QName> register( @NonNull private static Stream> getItemInterfaces(@NonNull Class clazz) { - @SuppressWarnings("unchecked") Stream> retval = IItem.class.isAssignableFrom(clazz) + @SuppressWarnings("unchecked") + Stream> retval = IItem.class.isAssignableFrom(clazz) ? Stream.of((Class) clazz) : Stream.empty(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java index 4cc2b3945..db6b14002 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIntegerItem.java @@ -55,7 +55,8 @@ static IIntegerItem valueOf(@NonNull String value) { @NonNull static IIntegerItem valueOf(int value) { @SuppressWarnings("null") - @NonNull BigInteger bigInteger = BigInteger.valueOf(value); + @NonNull + BigInteger bigInteger = BigInteger.valueOf(value); return valueOf(bigInteger); } @@ -69,7 +70,8 @@ static IIntegerItem valueOf(int value) { @NonNull static IIntegerItem valueOf(long value) { @SuppressWarnings("null") - @NonNull BigInteger bigInteger = BigInteger.valueOf(value); + @NonNull + BigInteger bigInteger = BigInteger.valueOf(value); return valueOf(bigInteger); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/INumericItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/INumericItem.java index 19494d836..6bab669ca 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/INumericItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/INumericItem.java @@ -146,7 +146,8 @@ default INumericItem round(@NonNull IIntegerItem precisionItem) { BigInteger value = asInteger(); BigInteger divisor = BigInteger.TEN.pow(0 - precision); - @NonNull BigInteger result; + @NonNull + BigInteger result; if (divisor.compareTo(value.abs()) > 0) { result = ObjectUtils.notNull(BigInteger.ZERO); } else { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java index cf005e1ff..d5c516c55 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java @@ -182,7 +182,8 @@ private IAssemblyNodeItem getCycledInstance( @NonNull IAssemblyNodeItem parent, int position, @NonNull Object value) { - @NonNull IModelNodeItem item; + @NonNull + IModelNodeItem item; if (instance instanceof IAssemblyInstance) { item = newAssemblyNodeItem((IAssemblyInstance) instance, parent, position, value); } else if (instance instanceof IFieldInstance) { @@ -208,7 +209,8 @@ private IAssemblyNodeItem getCycledInstance( protected IModelNodeItem newModelItem( @NonNull INamedModelInstance instance, @NonNull IAssemblyNodeItem parent) { - @NonNull IModelNodeItem item; + @NonNull + IModelNodeItem item; if (instance instanceof IAssemblyInstance) { item = newAssemblyNodeItem((IAssemblyInstance) instance, parent); } else if (instance instanceof IFieldInstance) { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFieldNodeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFieldNodeItem.java index ca24671f6..c0f7bbabf 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFieldNodeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFieldNodeItem.java @@ -35,7 +35,8 @@ default URI getBaseUri() { } @Override - default @NonNull String format(@NonNull IPathFormatter formatter) { + default @NonNull + String format(@NonNull IPathFormatter formatter) { return formatter.formatField(this); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFlagNodeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFlagNodeItem.java index f87bbb3d8..099173c82 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFlagNodeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFlagNodeItem.java @@ -72,7 +72,8 @@ default IFlagNodeItem getFlagByName(@NonNull QName name) { */ @SuppressWarnings("null") @Override - default @NonNull Stream flags() { + default @NonNull + Stream flags() { // a flag does not have flags return Stream.empty(); } @@ -83,7 +84,8 @@ default IFlagNodeItem getFlagByName(@NonNull QName name) { */ @SuppressWarnings("null") @Override - default @NonNull Collection>> getModelItems() { + default @NonNull + Collection>> getModelItems() { // a flag does not have model items return Collections.emptyList(); } @@ -111,7 +113,8 @@ default IFlagNodeItem getFlagByName(@NonNull QName name) { } @Override - default @NonNull String format(@NonNull IPathFormatter formatter) { + default @NonNull + String format(@NonNull IPathFormatter formatter) { return formatter.formatFlag(this); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java index a034da7f4..aeb750c8c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java @@ -79,7 +79,8 @@ protected M parseResource(@NonNull URI resource, @NonNull Deque visitedReso // now check if this Metaschema imports other metaschema List imports = getImports(binding); - @NonNull Map importedModules; + @NonNull + Map importedModules; if (imports.isEmpty()) { importedModules = ObjectUtils.notNull(Collections.emptyMap()); } else { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java index 71be91498..9a76e490f 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java @@ -79,7 +79,8 @@ default String getGroupAsXmlNamespace() { // REFACTOR: consider pushing down the call for getGroupAsXmlNamespace @NonNull default String getEffectiveGroupAsNamespace() { - @Nullable String namespace = getGroupAsXmlNamespace(); + @Nullable + String namespace = getGroupAsXmlNamespace(); if (namespace == null) { namespace = ObjectUtils.notNull(getContainingModule().getXmlNamespace().toASCIIString()); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamed.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamed.java index ebae35532..a058afcf9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamed.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamed.java @@ -48,7 +48,8 @@ default String getUseName() { // from INamedModelElement @NonNull default String getEffectiveName() { - @Nullable String useName = getUseName(); + @Nullable + String useName = getUseName(); return useName == null ? getName() : useName; } @@ -126,7 +127,8 @@ default Integer getUseIndex() { // from INamedModelElement @Nullable default Integer getEffectiveIndex() { - @Nullable Integer useIndex = getUseIndex(); + @Nullable + Integer useIndex = getUseIndex(); return useIndex == null ? getIndex() : useIndex; } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceAbsolute.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceAbsolute.java index 867353144..02ced5b07 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceAbsolute.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceAbsolute.java @@ -13,9 +13,11 @@ public interface INamedModelInstanceAbsolute extends INamedModelInstance, IModelInstanceAbsolute { @Override default String getJsonName() { - @NonNull String retval; + @NonNull + String retval; if (getMaxOccurs() == -1 || getMaxOccurs() > 1) { - @NonNull String groupAsName = ObjectUtils.requireNonNull(getGroupAsName(), + @NonNull + String groupAsName = ObjectUtils.requireNonNull(getGroupAsName(), ObjectUtils.notNull(String.format("null group-as name in instance '%s' on definition '%s' in '%s'", this.getName(), this.getContainingDefinition().getName(), diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java index 314f636b7..57721a675 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java @@ -779,7 +779,8 @@ protected void updateValueStatus( @NonNull IDefinitionNodeItem node) { // constraint.getAllowedValues().containsKey(value) - @Nullable ValueStatus valueStatus = valueMap.get(targetItem); + @Nullable + ValueStatus valueStatus = valueMap.get(targetItem); if (valueStatus == null) { valueStatus = new ValueStatus(targetItem); valueMap.put(targetItem, valueStatus); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java index 4d0ec45d2..15d6ea1f5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java @@ -98,7 +98,8 @@ public static CharSequence toString(XMLEvent xmlEvent) { retval = "EOF"; } else { @SuppressWarnings("null") - @NonNull StringBuilder builder = new StringBuilder() + @NonNull + StringBuilder builder = new StringBuilder() .append(toEventName(xmlEvent)); QName name = toQName(xmlEvent); if (name != null) { @@ -149,7 +150,8 @@ public static CharSequence toString(@NonNull XMLStreamReader2 reader) { // NO_UC int type = reader.getEventType(); @SuppressWarnings("null") - @NonNull StringBuilder builder = new StringBuilder().append(toEventName(type)); + @NonNull + StringBuilder builder = new StringBuilder().append(toEventName(type)); QName name = reader.getName(); if (name != null) { builder.append(": ").append(name.toString()); @@ -341,7 +343,8 @@ public static XMLEvent skipProcessingInstructions(@NonNull XMLEventReader2 reade @SuppressWarnings("null") @NonNull public static XMLEvent skipWhitespace(@NonNull XMLEventReader2 reader) throws XMLStreamException { - @NonNull XMLEvent nextEvent; + @NonNull + XMLEvent nextEvent; while ((nextEvent = reader.peek()).isCharacters()) { Characters characters = nextEvent.asCharacters(); String data = characters.getData(); diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupStringTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupStringTest.java index 2dcd3f8b6..31dce6abc 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupStringTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupStringTest.java @@ -130,7 +130,8 @@ void markupLineFromMarkdownTest() { } // InsertAnchorNode[0, 0] name:[39, 45, "insert"] { - @SuppressWarnings("unused") InsertAnchorNode insert = (InsertAnchorNode) paragraphChildren.get(5); + @SuppressWarnings("unused") + InsertAnchorNode insert = (InsertAnchorNode) paragraphChildren.get(5); } // Text[48, 49] chars:[48, 49, "."] { diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ExpressionUtilsTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ExpressionUtilsTest.java index bbcae5ebd..515c9991c 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ExpressionUtilsTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/ExpressionUtilsTest.java @@ -56,7 +56,8 @@ void testTwoFlags() { will(returnValue(IFlagNodeItem.class)); } }); - @SuppressWarnings("null") Class result + @SuppressWarnings("null") + Class result = ExpressionUtils.analyzeStaticResultType(baseType, List.of(basicFlagExpr1, basicFlagExpr2)); assertEquals(IFlagNodeItem.class, result); } @@ -73,7 +74,8 @@ void testFlagAndAssembly() { will(returnValue(IAssemblyNodeItem.class)); } }); - @SuppressWarnings("null") Class result + @SuppressWarnings("null") + Class result = ExpressionUtils.analyzeStaticResultType(baseType, List.of(basicFlagExpr1, basicAssemblyExpr)); assertEquals(IDefinitionNodeItem.class, result); } @@ -90,7 +92,8 @@ void testFieldAndAssembly() { will(returnValue(IAssemblyNodeItem.class)); } }); - @SuppressWarnings("null") Class result + @SuppressWarnings("null") + Class result = ExpressionUtils.analyzeStaticResultType(baseType, List.of(basicFieldExpr, basicAssemblyExpr)); assertEquals(IModelNodeItem.class, result); } diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/FlagTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/FlagTest.java index 303e05305..b52cef02f 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/FlagTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/FlagTest.java @@ -34,7 +34,8 @@ void testFlagWithName() { Mockery context = getContext(); @SuppressWarnings("null") - @NonNull IModelNodeItem focusItem = context.mock(IModelNodeItem.class); + @NonNull + IModelNodeItem focusItem = context.mock(IModelNodeItem.class); IFlagInstance instance = context.mock(IFlagInstance.class); IFlagNodeItem flagNode = context.mock(IFlagNodeItem.class); diff --git a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpressionTest.java b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpressionTest.java index e02dcb7de..6c2f12542 100644 --- a/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpressionTest.java +++ b/core/src/test/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpressionTest.java @@ -33,12 +33,15 @@ void testPredicateWithValues() { Mockery context = getContext(); @SuppressWarnings("null") - @NonNull IExpression stepExpr = context.mock(IExpression.class); + @NonNull + IExpression stepExpr = context.mock(IExpression.class); ISequence stepResult = context.mock(ISequence.class, "stepResult"); @SuppressWarnings("null") - @NonNull IAssemblyNodeItem item = context.mock(IAssemblyNodeItem.class); + @NonNull + IAssemblyNodeItem item = context.mock(IAssemblyNodeItem.class); @SuppressWarnings({ "unchecked", "null" }) - @NonNull List predicates = context.mock(List.class, "predicates"); + @NonNull + List predicates = context.mock(List.class, "predicates"); context.checking(new Expectations() { { // NOPMD - intentional @@ -74,12 +77,15 @@ void testPredicateWithoutValues() { Mockery context = getContext(); @SuppressWarnings("null") - @NonNull IExpression stepExpr = context.mock(IExpression.class); + @NonNull + IExpression stepExpr = context.mock(IExpression.class); ISequence stepResult = context.mock(ISequence.class, "stepResult"); @SuppressWarnings("null") - @NonNull IAssemblyNodeItem item = context.mock(IAssemblyNodeItem.class); + @NonNull + IAssemblyNodeItem item = context.mock(IAssemblyNodeItem.class); @SuppressWarnings({ "unchecked", "null" }) - @NonNull List predicates = context.mock(List.class, "predicates"); + @NonNull + List predicates = context.mock(List.class, "predicates"); context.checking(new Expectations() { { // NOPMD - intentional diff --git a/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java b/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java index 49a2b55d4..31b4e779b 100644 --- a/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java +++ b/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java @@ -466,7 +466,8 @@ public List generateResults(@NonNull URI output) throws IOException { assert constraint != null; ConstraintRuleRecord rule = getRuleRecord(constraint); - @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") Result result = new Result(); + @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") + Result result = new Result(); String id = constraint.getId(); if (id != null) { 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 7492495c4..890092d85 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 @@ -826,7 +826,8 @@ default IValidationResult validateWithSchema( switch (asFormat) { case JSON: { JSONObject json; - try (@SuppressWarnings("resource") InputStream is + try (@SuppressWarnings("resource") + InputStream is = new BufferedInputStream(ObjectUtils.notNull(targetResource.openStream()))) { json = new JSONObject(new JSONTokener(is)); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java index 8449efa0b..28ac6466c 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java @@ -106,7 +106,8 @@ public String getClassName(IModelDefinition definition) { } @Override - public @NonNull String getClassName(@NonNull IModule module) { + public @NonNull + String getClassName(@NonNull IModule module) { // TODO: make this configurable return ClassUtils.toClassName(module.getShortName() + "Module"); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractModelInstanceTypeInfo.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractModelInstanceTypeInfo.java index 94c643e9f..bf0456d5a 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractModelInstanceTypeInfo.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractModelInstanceTypeInfo.java @@ -52,10 +52,12 @@ public String getBaseName() { } @Override - public @NonNull TypeName getJavaFieldType() { + public @NonNull + TypeName getJavaFieldType() { TypeName item = getJavaItemType(); - @NonNull TypeName retval; + @NonNull + TypeName retval; IModelInstanceAbsolute instance = getInstance(); int maxOccurance = instance.getMaxOccurs(); if (maxOccurance == -1 || maxOccurance > 1) { diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java index 8320a531d..b9501ab85 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java @@ -43,7 +43,8 @@ public AbstractNamedModelInstanceTypeInfo( } @Override - public @NonNull String getBaseName() { + public @NonNull + String getBaseName() { INSTANCE modelInstance = getInstance(); String retval; if (modelInstance.getMaxOccurs() == -1 || modelInstance.getMaxOccurs() > 1) { diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java index 8912a90da..37e665e41 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java @@ -240,7 +240,8 @@ private String generateClassName( @NonNull String packageOrTypeName, @NonNull String suggestedClassName, @NonNull IModelDefinition definition) { - @NonNull String retval = suggestedClassName; + @NonNull + String retval = suggestedClassName; boolean clash = false; classNameLock.lock(); try { 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 bd7ede0d6..824cfd4a8 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 @@ -425,7 +425,8 @@ private IBoundObject readComplexDefinitionObject( ? bodyHandler : new JsonKeyBodyHandler(jsonKey, bodyHandler); - @SuppressWarnings("resource") JsonLocation location = getReader().currentLocation(); + @SuppressWarnings("resource") + JsonLocation location = getReader().currentLocation(); // construct the item IBoundObject item = definition.newInstance( @@ -504,7 +505,8 @@ public void accept( IBoundObject parent, IJsonProblemHandler problemHandler) throws IOException { - @SuppressWarnings("resource") JsonParser parser = getReader(); + @SuppressWarnings("resource") + JsonParser parser = getReader(); JsonUtil.assertCurrent(parser, JsonToken.FIELD_NAME); // the field will be the JSON key @@ -550,7 +552,8 @@ public void accept( IBoundObject parent, IJsonProblemHandler problemHandler) throws IOException { - @SuppressWarnings("resource") JsonParser parser = getReader(); + @SuppressWarnings("resource") + JsonParser parser = getReader(); // advance past the start object JsonUtil.assertAndAdvance(parser, JsonToken.START_OBJECT); @@ -753,7 +756,8 @@ public Map readMap() throws IOException { IBoundInstanceModel instance = getCollectionInfo().getInstance(); - @SuppressWarnings("PMD.UseConcurrentHashMap") Map items = new LinkedHashMap<>(); + @SuppressWarnings("PMD.UseConcurrentHashMap") + Map items = new LinkedHashMap<>(); // A map value is always wrapped in a START_OBJECT, since fields are used for // the keys diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonWriter.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonWriter.java index b1f1c4b3d..4e222f2d2 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonWriter.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/MetaschemaJsonWriter.java @@ -74,7 +74,8 @@ public void write( private void writeInstance( @NonNull IBoundProperty instance, @NonNull IBoundObject parentItem) throws IOException { - @SuppressWarnings("unchecked") T value = (T) instance.getValue(parentItem); + @SuppressWarnings("unchecked") + T value = (T) instance.getValue(parentItem); if (value != null && !value.equals(instance.getResolvedDefaultValue())) { generator.writeFieldName(instance.getJsonName()); instance.writeItem(value, this); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/NullJavaTypeAdapter.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/NullJavaTypeAdapter.java index e084d95a0..c7776e80e 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/NullJavaTypeAdapter.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/NullJavaTypeAdapter.java @@ -78,12 +78,14 @@ public Void getValue() { } @Override - public @NonNull IAnyAtomicItem toAtomicItem() { + public @NonNull + IAnyAtomicItem toAtomicItem() { throw new UnsupportedOperationException(NOT_VALID); } @Override - public @NonNull String asString() { + public @NonNull + String asString() { throw new UnsupportedOperationException(NOT_VALID); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/IFeatureComplexItemValueHandler.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/IFeatureComplexItemValueHandler.java index 5b13a8332..2dd007e4b 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/IFeatureComplexItemValueHandler.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/IFeatureComplexItemValueHandler.java @@ -81,11 +81,13 @@ default CLASS newInstance(@Nullable Supplier constructor + @SuppressWarnings("unchecked") + Constructor constructor = (Constructor) clazz.getDeclaredConstructor(IMetaschemaData.class); retval = constructor.newInstance(supplier.get()); } else { - @SuppressWarnings("unchecked") Constructor constructor + @SuppressWarnings("unchecked") + Constructor constructor = (Constructor) clazz.getDeclaredConstructor(); retval = constructor.newInstance(); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/SingletonCollectionInfo.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/SingletonCollectionInfo.java index 3749d81be..93ef2af2b 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/SingletonCollectionInfo.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/info/SingletonCollectionInfo.java @@ -51,7 +51,8 @@ public Object deepCopyItems(@NonNull IBoundObject fromObject, @NonNull IBoundObj throws BindingException { IBoundInstanceModel instance = getInstance(); - @SuppressWarnings("unchecked") ITEM value = (ITEM) instance.getValue(fromObject); + @SuppressWarnings("unchecked") + ITEM value = (ITEM) instance.getValue(fromObject); return value == null ? null : instance.deepCopyItem(ObjectUtils.requireNonNull(value), toObject); } 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 617385667..f68092fe1 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 @@ -100,7 +100,8 @@ protected List parseResource(@NonNull URI resource, @NonNull Deq // now check if this constraint set imports other constraint sets List imports = CollectionUtil.listOrEmpty(obj.getImports()); - @NonNull Set importedConstraints; + @NonNull + Set importedConstraints; if (imports.isEmpty()) { importedConstraints = CollectionUtil.emptySet(); } else { diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/MetaschemaModelModule.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/MetaschemaModelModule.java index 89fd3469f..93930586f 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/MetaschemaModelModule.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/MetaschemaModelModule.java @@ -84,7 +84,8 @@ public final class MetaschemaModelModule private static final Map NAMESPACE_BINDINGS; static { - @SuppressWarnings("PMD.UseConcurrentHashMap") Map bindings = new LinkedHashMap<>(); + @SuppressWarnings("PMD.UseConcurrentHashMap") + Map bindings = new LinkedHashMap<>(); NAMESPACE_BINDINGS = bindings; } diff --git a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java index ae428094a..9e2ddacae 100644 --- a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java +++ b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java @@ -86,7 +86,8 @@ private static void write( @NonNull Path file, @NonNull T rootObject, @NonNull IBindingContext context) throws IOException { - @SuppressWarnings("unchecked") Class clazz = (Class) rootObject.getClass(); + @SuppressWarnings("unchecked") + Class clazz = (Class) rootObject.getClass(); try (Writer writer = Files.newBufferedWriter(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) { diff --git a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java index 182b3f026..3600a6ccc 100644 --- a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java +++ b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java @@ -101,7 +101,8 @@ void testFieldsWithFlagMetaschema() assertEquals("complex-field1", reflectMethod(field1, "getId")); assertEquals("test-string", reflectMethod(field1, "getValue")); - @SuppressWarnings("unchecked") List field2s + @SuppressWarnings("unchecked") + List field2s = (List) ReflectionUtils.invokeMethod(obj.getClass().getMethod("getComplexFields2"), obj); assertNotNull(field2s); @@ -110,7 +111,8 @@ void testFieldsWithFlagMetaschema() assertEquals("complex-field2-1", reflectMethod(field2, "getId")); assertEquals("test-string2", reflectMethod(field2, "getValue")); - @SuppressWarnings("unchecked") List field3s + @SuppressWarnings("unchecked") + List field3s = (List) ReflectionUtils.invokeMethod(obj.getClass().getMethod("getComplexFields3"), obj); assertEquals(2, field3s.size()); @@ -126,7 +128,8 @@ void testFieldsWithFlagMetaschema() }); assertAll("ComplexFields4", () -> { - @SuppressWarnings("unchecked") Map collection + @SuppressWarnings("unchecked") + Map collection = (Map) ReflectionUtils.invokeMethod(obj.getClass().getMethod("getComplexFields4"), obj); assertNotNull(collection, "ComplexFields4 collection is null"); diff --git a/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSchemaMojo.java b/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSchemaMojo.java index 57eaa879b..b75764551 100644 --- a/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSchemaMojo.java +++ b/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSchemaMojo.java @@ -214,7 +214,8 @@ private static void generateSchema( @NonNull IConfiguration> schemaGenerationConfig, @NonNull Path schemaPath, @NonNull ISchemaGenerator generator) throws IOException { - try (@SuppressWarnings("resource") Writer writer = ObjectUtils.notNull(Files.newBufferedWriter( + try (@SuppressWarnings("resource") + Writer writer = ObjectUtils.notNull(Files.newBufferedWriter( schemaPath, StandardCharsets.UTF_8, StandardOpenOption.CREATE, diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java index 9c67e1872..31a2c3d95 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java @@ -84,7 +84,8 @@ public void generateFromModule( IConfiguration> configuration) { try { // avoid automatically closing streams not owned by the generator - @SuppressWarnings({ "PMD.CloseResource", "resource" }) T schemaWriter = newWriter(out); + @SuppressWarnings({ "PMD.CloseResource", "resource" }) + T schemaWriter = newWriter(out); S generationState = newGenerationState(metaschema, schemaWriter, configuration); generateSchema(generationState); generationState.flushWriter(); diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java index 177bb6e15..d7a7ad34e 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java @@ -111,7 +111,8 @@ protected void generateSchema(JsonGenerationState state) { }) .collect(Collectors.toUnmodifiableList()); - @SuppressWarnings("resource") JsonGenerator writer = state.getWriter(); // NOPMD not owned + @SuppressWarnings("resource") + JsonGenerator writer = state.getWriter(); // NOPMD not owned if (rootEntries.size() == 1) { rootEntries.iterator().next().write(writer); diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/AssemblyDefinitionJsonSchema.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/AssemblyDefinitionJsonSchema.java index 0ff6169a1..4db351da6 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/AssemblyDefinitionJsonSchema.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/AssemblyDefinitionJsonSchema.java @@ -179,7 +179,8 @@ protected List explodeChoices( // iterate over the old array of choices and append new choice for (PropertyCollection oldInstanceProperties : retval) { @SuppressWarnings("null") - @NonNull PropertyCollection newInstanceProperties = oldInstanceProperties.copy(); + @NonNull + PropertyCollection newInstanceProperties = oldInstanceProperties.copy(); // add the choice choiceInstances.get(optionInstance) diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/JsonGenerationState.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/JsonGenerationState.java index 788d7baa6..60c3122ef 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/JsonGenerationState.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/json/impl/JsonGenerationState.java @@ -173,7 +173,8 @@ private static IDefinitionJsonSchema newJsonSchema( } public ObjectNode generateDefinitions() { - @NonNull Map> gatheredDefinitions = new HashMap<>(); + @NonNull + Map> gatheredDefinitions = new HashMap<>(); getMetaschemaIndex().getDefinitions().stream() .filter(DefinitionEntry::isRoot) diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/DocumentationGenerator.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/DocumentationGenerator.java index 6daf90807..9f750323a 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/DocumentationGenerator.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/DocumentationGenerator.java @@ -24,10 +24,14 @@ public final class DocumentationGenerator { - private final @Nullable String formalName; - private final @Nullable MarkupLine description; - private final @NonNull List remarks; - private final @NonNull IModelElement modelElement; + @Nullable + private final String formalName; + @Nullable + private final MarkupLine description; + @NonNull + private final List remarks; + @NonNull + private final IModelElement modelElement; private DocumentationGenerator(@NonNull IDefinition definition) { this.formalName = definition.getEffectiveFormalName(); diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseBaseDatatypeProvider.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseBaseDatatypeProvider.java index 14cd3427e..fbbf7dd61 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseBaseDatatypeProvider.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseBaseDatatypeProvider.java @@ -34,7 +34,8 @@ protected List queryElements(JDom2XmlSchemaLoader loader) { } @Override - protected @NonNull Map handleResults(@NonNull List items) { + @NonNull + protected Map handleResults(@NonNull List items) { return CollectionUtil.singletonMap( DATATYPE_NAME, new JDom2DatatypeContent( diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseCompositDatatypeProvider.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseCompositDatatypeProvider.java index 394b68b4c..d5f11fcf2 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseCompositDatatypeProvider.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/impl/XmlProseCompositDatatypeProvider.java @@ -26,7 +26,8 @@ public XmlProseCompositDatatypeProvider(@NonNull List proxied } @Override - public @NonNull Set generateDatatypes(Set requiredTypes, + @NonNull + public Set generateDatatypes(Set requiredTypes, @NonNull XMLStreamWriter2 writer) throws XMLStreamException { Set result = super.generateDatatypes(requiredTypes, writer); @@ -38,5 +39,4 @@ public XmlProseCompositDatatypeProvider(@NonNull List proxied } return result; } - } diff --git a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java index b207d0f29..16def5a13 100644 --- a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java +++ b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java @@ -111,10 +111,12 @@ public abstract class AbstractSchemaGeneratorTestSuite } @SuppressWarnings("null") - @NonNull Function xmlContentValidatorProvider = path -> { + @NonNull + Function xmlContentValidatorProvider = path -> { try { URL schemaResource = path.toUri().toURL(); - @SuppressWarnings("resource") StreamSource source + @SuppressWarnings("resource") + StreamSource source = new StreamSource(schemaResource.openStream(), schemaResource.toString()); List schemaSources = Collections.singletonList(source); return new XmlSchemaContentValidator(schemaSources); @@ -124,7 +126,8 @@ public abstract class AbstractSchemaGeneratorTestSuite }; XML_CONTENT_VALIDATOR_PROVIDER = xmlContentValidatorProvider; - @NonNull Function jsonContentValidatorProvider = path -> { + @NonNull + Function jsonContentValidatorProvider = path -> { try (InputStream is = Files.newInputStream(path, StandardOpenOption.READ)) { assert is != null; return new JsonSchemaContentValidator(is);