Skip to content

Commit 40f3805

Browse files
Reworked definition and instance model classes to reduce extra interfaces and to simplify and align implementations.
1 parent c8ef0d7 commit 40f3805

File tree

298 files changed

+4074
-5994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+4074
-5994
lines changed

core/src/main/java/gov/nist/secauto/metaschema/core/datatype/AbstractDataTypeProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public List<? extends IDataTypeAdapter<?>> getJavaTypeAdapters() {
6161
* if another type adapter has no name
6262
*/
6363
protected void registerDatatype(@NonNull IDataTypeAdapter<?> adapter) {
64-
if (adapter.getNames().size() == 0) {
64+
if (adapter.getNames().isEmpty()) {
6565
throw new IllegalArgumentException("The adapter has no name: " + adapter.getClass().getName());
6666
}
6767
synchronized (this) {

core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/flexmark/HtmlQuoteTagExtension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public HtmlNodeRenderer apply(DataHolder options) {
172172
public static class DoubleQuoteNode
173173
extends TypographicQuotes {
174174

175+
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
175176
public DoubleQuoteNode(TypographicQuotes node) {
176177
super(node.getOpeningMarker(), node.getText(), node.getClosingMarker());
177178
setTypographicOpening(node.getTypographicOpening());

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/ISequence.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public Supplier<List<ITEM_TYPE>> supplier() {
240240

241241
@Override
242242
public BiConsumer<List<ITEM_TYPE>, ITEM_TYPE> accumulator() {
243-
return (list, value) -> list.add(value);
243+
return List::add;
244244
}
245245

246246
@Override
@@ -280,7 +280,7 @@ static <T extends R, R extends IItem> ISequence<R> map(
280280
@NonNull Function<T, R> mapFunction,
281281
@NonNull ISequence<T> seq) {
282282
return seq.safeStream()
283-
.map(item -> mapFunction.apply(item))
283+
.map(mapFunction::apply)
284284
.collect(toSequence());
285285
}
286286

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/BuildCSTVisitor.java

Lines changed: 86 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ public BuildCSTVisitor(@NonNull StaticContext context) {
138138
this.context = context;
139139
}
140140

141-
/* ============================================================
142-
* Expressions - https://www.w3.org/TR/xpath-31/#id-expressions
141+
/*
142+
* ============================================================ Expressions -
143+
* https://www.w3.org/TR/xpath-31/#id-expressions
143144
* ============================================================
144145
*/
145146
@NonNull
@@ -155,8 +156,9 @@ protected IExpression handleExpr(ExprContext ctx) {
155156
});
156157
}
157158

158-
/* =================================================================
159-
* Literal Expressions - https://www.w3.org/TR/xpath-31/#id-literals
159+
/*
160+
* ================================================================= Literal
161+
* Expressions - https://www.w3.org/TR/xpath-31/#id-literals
160162
* =================================================================
161163
*/
162164

@@ -185,8 +187,9 @@ protected IExpression handleNumericLiteral(NumericliteralContext ctx) {
185187
return retval;
186188
}
187189

188-
/* ==================================================================
189-
* Variable References - https://www.w3.org/TR/xpath-31/#id-variables
190+
/*
191+
* ================================================================== Variable
192+
* References - https://www.w3.org/TR/xpath-31/#id-variables
190193
* ==================================================================
191194
*/
192195

@@ -198,8 +201,9 @@ protected IExpression handleVarref(VarrefContext ctx) {
198201
getContext().getVariablePrefixResolver()));
199202
}
200203

201-
/* ====================================================================
202-
* For Expressions - https://www.w3.org/TR/xpath-31/#id-for-expressions
204+
/*
205+
* ==================================================================== For
206+
* Expressions - https://www.w3.org/TR/xpath-31/#id-for-expressions
203207
* ====================================================================
204208
*/
205209

@@ -234,8 +238,9 @@ protected IExpression handleForexpr(ForexprContext ctx) {
234238
return retval;
235239
}
236240

237-
/* ====================================================================
238-
* Let Expressions - https://www.w3.org/TR/xpath-31/#id-let-expressions
241+
/*
242+
* ==================================================================== Let
243+
* Expressions - https://www.w3.org/TR/xpath-31/#id-let-expressions
239244
* ====================================================================
240245
*/
241246

@@ -262,9 +267,12 @@ protected IExpression handleLet(LetexprContext context) {
262267
return retval;
263268
}
264269

265-
/* ==================================================================================
266-
* Quantified Expressions - https://www.w3.org/TR/xpath-31/#id-quantified-expressions
267-
* ==================================================================================
270+
/*
271+
* =============================================================================
272+
* ===== Quantified Expressions -
273+
* https://www.w3.org/TR/xpath-31/#id-quantified-expressions
274+
* =============================================================================
275+
* =====
268276
*/
269277

270278
@Override
@@ -302,8 +310,9 @@ protected IExpression handleQuantifiedexpr(QuantifiedexprContext ctx) {
302310
return new Quantified(quantifier, vars, satisfies);
303311
}
304312

305-
/* =======================================================================
306-
* Arrow operator (=>) - https://www.w3.org/TR/xpath-31/#id-arrow-operator
313+
/*
314+
* ======================================================================= Arrow
315+
* operator (=>) - https://www.w3.org/TR/xpath-31/#id-arrow-operator
307316
* =======================================================================
308317
*/
309318

@@ -333,27 +342,34 @@ protected IExpression handleArrowexpr(ArrowexprContext context) {
333342
});
334343
}
335344

336-
/* =================================================================================
337-
* Parenthesized Expressions - https://www.w3.org/TR/xpath-31/#id-paren-expressions
338-
* =================================================================================
345+
/*
346+
* =============================================================================
347+
* ==== Parenthesized Expressions -
348+
* https://www.w3.org/TR/xpath-31/#id-paren-expressions
349+
* =============================================================================
350+
* ====
339351
*/
340352

341353
@Override
342354
protected IExpression handleEmptyParenthesizedexpr(ParenthesizedexprContext ctx) {
343355
return EmptySequence.instance();
344356
}
345357

346-
/* =====================================================================================
347-
* Context Item Expression - https://www.w3.org/TR/xpath-31/#id-context-item-expression
348-
* =====================================================================================
358+
/*
359+
* =============================================================================
360+
* ======== Context Item Expression -
361+
* https://www.w3.org/TR/xpath-31/#id-context-item-expression
362+
* =============================================================================
363+
* ========
349364
*/
350365

351366
@Override
352367
protected IExpression handleContextitemexpr(ContextitemexprContext ctx) {
353368
return ContextItem.instance();
354369
}
355370

356-
/* =========================================================================
371+
/*
372+
* =========================================================================
357373
* Static Function Calls - https://www.w3.org/TR/xpath-31/#id-function-calls
358374
* =========================================================================
359375
*/
@@ -396,7 +412,8 @@ protected IExpression handleFunctioncall(FunctioncallContext ctx) {
396412
.collect(Collectors.toUnmodifiableList())));
397413
}
398414

399-
/* =========================================================================
415+
/*
416+
* =========================================================================
400417
* Filter Expressions - https://www.w3.org/TR/xpath-31/#id-filter-expression
401418
* =========================================================================
402419
*/
@@ -461,8 +478,9 @@ protected IExpression handlePostfixexpr(PostfixexprContext ctx) {
461478
}
462479
return retval;
463480
}
464-
/* ======================================================================
465-
* Path Expressions - https://www.w3.org/TR/xpath-31/#id-path-expressions
481+
/*
482+
* ====================================================================== Path
483+
* Expressions - https://www.w3.org/TR/xpath-31/#id-path-expressions
466484
* ======================================================================
467485
*/
468486

@@ -498,9 +516,12 @@ protected IExpression handlePathexpr(PathexprContext ctx) {
498516
return retval;
499517
}
500518

501-
/* =======================================================================================
502-
* RelativePath Expressions - https://www.w3.org/TR/xpath-31/#id-relative-path-expressions
503-
* =======================================================================================
519+
/*
520+
* =============================================================================
521+
* ========== RelativePath Expressions -
522+
* https://www.w3.org/TR/xpath-31/#id-relative-path-expressions
523+
* =============================================================================
524+
* ==========
504525
*/
505526

506527
@Override
@@ -528,8 +549,9 @@ protected IExpression handleRelativepathexpr(RelativepathexprContext context) {
528549
});
529550
}
530551

531-
/* ================================================
532-
* Steps - https://www.w3.org/TR/xpath-31/#id-steps
552+
/*
553+
* ================================================ Steps -
554+
* https://www.w3.org/TR/xpath-31/#id-steps
533555
* ================================================
534556
*/
535557

@@ -594,13 +616,15 @@ protected IExpression handleReversestep(ReversestepContext ctx) {
594616
return new Step(axis, parseNodeTest(ctx.nodetest(), false));
595617
}
596618

597-
/* =======================================================
598-
* Node Tests - https://www.w3.org/TR/xpath-31/#node-tests
619+
/*
620+
* ======================================================= Node Tests -
621+
* https://www.w3.org/TR/xpath-31/#node-tests
599622
* =======================================================
600623
*/
601624

602-
/* =======================================================
603-
* Node Tests - https://www.w3.org/TR/xpath-31/#node-tests
625+
/*
626+
* ======================================================= Node Tests -
627+
* https://www.w3.org/TR/xpath-31/#node-tests
604628
* =======================================================
605629
*/
606630

@@ -627,17 +651,16 @@ protected INameTestExpression parseNameTest(NametestContext ctx, boolean flag) {
627651
@Override
628652
protected Wildcard handleWildcard(WildcardContext ctx) {
629653
Predicate<IDefinitionNodeItem<?, ?>> matcher = null;
630-
TerminalNode node;
631-
if ((node = ctx.STAR()) == null) {
632-
if ((node = ctx.CS()) != null) {
654+
if (ctx.STAR() == null) {
655+
if (ctx.CS() != null) {
633656
// specified prefix, any local-name
634657
String prefix = ctx.NCName().getText();
635658
String namespace = getContext().lookupNamespaceForPrefix(prefix);
636659
if (namespace == null) {
637660
throw new IllegalStateException(String.format("Prefix '%s' did not map to a namespace.", prefix));
638661
}
639662
matcher = new Wildcard.MatchAnyLocalName(namespace);
640-
} else if ((node = ctx.SC()) != null) {
663+
} else if (ctx.SC() != null) {
641664
// any prefix, specified local-name
642665
matcher = new Wildcard.MatchAnyNamespace(ctx.NCName().getText());
643666
} else {
@@ -651,7 +674,8 @@ protected Wildcard handleWildcard(WildcardContext ctx) {
651674
return new Wildcard(matcher);
652675
}
653676

654-
/* ======================================================================
677+
/*
678+
* ======================================================================
655679
* Predicates within Steps - https://www.w3.org/TR/xpath-31/#id-predicate
656680
* ======================================================================
657681
*/
@@ -667,8 +691,9 @@ protected IExpression handleAxisstep(AxisstepContext ctx) {
667691
return predicates.isEmpty() ? step : new PredicateExpression(step, predicates);
668692
}
669693

670-
/* ===========================================================
671-
* Abbreviated Syntax - https://www.w3.org/TR/xpath-31/#abbrev
694+
/*
695+
* =========================================================== Abbreviated
696+
* Syntax - https://www.w3.org/TR/xpath-31/#abbrev
672697
* ===========================================================
673698
*/
674699

@@ -691,7 +716,8 @@ protected IExpression handleAbbrevreversestep(AbbrevreversestepContext ctx) {
691716
return Axis.PARENT;
692717
}
693718

694-
/* ======================================================================
719+
/*
720+
* ======================================================================
695721
* Constructing Sequences - https://www.w3.org/TR/xpath-31/#construct_seq
696722
* ======================================================================
697723
*/
@@ -706,7 +732,8 @@ protected IExpression handleRangeexpr(RangeexprContext ctx) {
706732
return new Range(left, right);
707733
}
708734

709-
/* ========================================================================
735+
/*
736+
* ========================================================================
710737
* Combining Node Sequences - https://www.w3.org/TR/xpath-31/#combining_seq
711738
* ========================================================================
712739
*/
@@ -744,7 +771,8 @@ protected IExpression handleIntersectexceptexpr(IntersectexceptexprContext conte
744771
});
745772
}
746773

747-
/* ======================================================================
774+
/*
775+
* ======================================================================
748776
* Arithmetic Expressions - https://www.w3.org/TR/xpath-31/#id-arithmetic
749777
* ======================================================================
750778
*/
@@ -835,9 +863,12 @@ protected IExpression handleUnaryexpr(UnaryexprContext ctx) {
835863
return retval;
836864
}
837865

838-
/* ========================================================================================
839-
* String Concatenation Expressions - https://www.w3.org/TR/xpath-31/#id-string-concat-expr
840-
* ========================================================================================
866+
/*
867+
* =============================================================================
868+
* =========== String Concatenation Expressions -
869+
* https://www.w3.org/TR/xpath-31/#id-string-concat-expr
870+
* =============================================================================
871+
* ===========
841872
*/
842873

843874
@Override
@@ -848,7 +879,8 @@ protected IExpression handleStringconcatexpr(StringconcatexprContext ctx) {
848879
});
849880
}
850881

851-
/* =======================================================================
882+
/*
883+
* =======================================================================
852884
* Comparison Expressions - https://www.w3.org/TR/xpath-31/#id-comparisons
853885
* =======================================================================
854886
*/
@@ -924,7 +956,8 @@ protected IExpression handleComparisonexpr(ComparisonexprContext ctx) { // NOPMD
924956
return retval;
925957
}
926958

927-
/* ============================================================================
959+
/*
960+
* ============================================================================
928961
* Logical Expressions - https://www.w3.org/TR/xpath-31/#id-logical-expressions
929962
* ============================================================================
930963
*/
@@ -945,7 +978,8 @@ protected IExpression handleAndexpr(AndexprContext ctx) {
945978
});
946979
}
947980

948-
/* =========================================================================
981+
/*
982+
* =========================================================================
949983
* Conditional Expressions - https://www.w3.org/TR/xpath-31/#id-conditionals
950984
* =========================================================================
951985
*/
@@ -959,7 +993,8 @@ protected IExpression handleIfexpr(IfexprContext ctx) {
959993
return new If(testExpr, thenExpr, elseExpr);
960994
}
961995

962-
/* =========================================================================
996+
/*
997+
* =========================================================================
963998
* Simple map operator (!) - https://www.w3.org/TR/xpath-31/#id-map-operator
964999
* =========================================================================
9651000
*/

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/ExpressionUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static <RESULT_TYPE> Class<? extends RESULT_TYPE> analyzeStaticResultType
6161
retval = baseType;
6262
} else {
6363
List<Class<?>> expressionClasses = ObjectUtils.notNull(expressions.stream()
64-
.map(expr -> expr.getStaticResultType()).collect(Collectors.toList()));
64+
.map(IExpression::getStaticResultType).collect(Collectors.toList()));
6565

6666
// check if the expression classes, are derived from the base type
6767
if (checkDerivedFrom(baseType, expressionClasses)) {

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/PredicateExpression.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.math.BigInteger;
3737
import java.util.List;
3838
import java.util.Map;
39+
import java.util.Map.Entry;
3940
import java.util.concurrent.atomic.AtomicInteger;
4041
import java.util.stream.Collectors;
4142
import java.util.stream.Stream;
@@ -125,7 +126,7 @@ public List<? extends IExpression> getChildren() {
125126
}
126127
return bool;
127128
}).anyMatch(x -> !x);
128-
}).map(entry -> entry.getValue()));
129+
}).map(Entry::getValue));
129130

130131
retval = ISequence.of(stream);
131132
}

core/src/main/java/gov/nist/secauto/metaschema/core/metapath/cst/path/AbstractPathExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected Stream<? extends INodeItem> searchExpression(
7676
= (Stream<? extends INodeItem>) expression.accept(dynamicContext, outerFocus).asStream();
7777

7878
Stream<? extends INodeItem> childMatches = outerFocus.asStream()
79-
.map(item -> ItemUtils.checkItemIsNodeItemForStep(item))
79+
.map(ItemUtils::checkItemIsNodeItemForStep)
8080
.flatMap(focusedNode -> {
8181

8282
Stream<? extends INodeItem> matches;

0 commit comments

Comments
 (0)