CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/IFeatureBindingContainerModel.java | 34 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/IFeatureBindingContainerModelAssembly.java | 42 |
IAssemblyInstanceAbsolute> getModelContainer(); @Override default Collection<IModelInstanceAbsolute> getModelInstances() { return getModelContainer().getModelInstances(); } @Override default INamedModelInstanceAbsolute getNamedModelInstanceByName(QName name) { return getModelContainer().getNamedModelInstanceMap().get(name); } @SuppressWarnings("null") @Override default Collection<INamedModelInstanceAbsolute> getNamedModelInstances() { return getModelContainer().getNamedModelInstanceMap().values(); } @Override default IFieldInstanceAbsolute getFieldInstanceByName(QName name) { return getModelContainer().getFieldInstanceMap().get(name); } @SuppressWarnings("null") @Override default Collection<IFieldInstanceAbsolute> getFieldInstances() { return getModelContainer().getFieldInstanceMap().values(); } @Override default IAssemblyInstanceAbsolute getAssemblyInstanceByName(QName name) { return getModelContainer().getAssemblyInstanceMap().get(name); } @SuppressWarnings("null") @Override default Collection<IAssemblyInstanceAbsolute> getAssemblyInstances() { return getModelContainer().getAssemblyInstanceMap().values(); } |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java | 96 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyInline.java | 110 |
this.properties = ModelSupport.parseProperties(ObjectUtils.requireNonNull(binding.getProps())); this.flagContainer = ObjectUtils.notNull(Lazy.lazy(() -> { JsonKey jsonKey = getBinding().getJsonKey(); return FlagContainerSupport.newFlagContainer( binding.getFlags(), bindingInstance, this, jsonKey == null ? null : jsonKey.getFlagRef()); })); this.modelContainer = ObjectUtils.notNull(Lazy.lazy(() -> AssemblyModelContainerSupport.of( binding.getModel(), ObjectUtils.requireNonNull(bindingInstance.getDefinition() .getAssemblyInstanceByName(XmlModuleConstants.MODEL_QNAME)), this, nodeItemFactory))); this.modelConstraints = ObjectUtils.notNull(Lazy.lazy(() -> { IModelConstrained retval = new AssemblyConstraintSet(); AssemblyConstraints constraints = getBinding().getConstraint(); if (constraints != null) { ConstraintBindingSupport.parse(retval, constraints, module.getSource()); |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldComplex.java | 102 |
gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldScalar.java | 86 |
IGroupAs groupAs = ModelUtil.resolveDefaultGroupAs( annotation.groupAs(), parent.getContainingModule()); if (annotation.maxOccurs() == -1 || annotation.maxOccurs() > 1) { if (IGroupAs.SINGLETON_GROUP_AS.equals(groupAs)) { throw new IllegalStateException(String.format("Field '%s' on class '%s' is missing the '%s' annotation.", javaField.getName(), javaField.getDeclaringClass().getName(), GroupAs.class.getName())); // NOPMD false positive } } else if (!IGroupAs.SINGLETON_GROUP_AS.equals(groupAs)) { // max is 1 and a groupAs is set throw new IllegalStateException( String.format( "Field '%s' on class '%s' has the '%s' annotation, but maxOccurs=1. A groupAs must not be specfied.", javaField.getName(), javaField.getDeclaringClass().getName(), GroupAs.class.getName())); // NOPMD false positive } return new InstanceModelFieldComplex(javaField, annotation, groupAs, definition, parent); |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/IBoundInstanceModel.java | 39 |
gov/nist/secauto/metaschema/databind/model/IBoundInstanceModel.java | 72 |
static Class<?> getItemType(@NonNull Field field) { Type fieldType = field.getGenericType(); Class<?> rawType = ObjectUtils.notNull( (Class<?>) (fieldType instanceof ParameterizedType ? ((ParameterizedType) fieldType).getRawType() : fieldType)); Class<?> itemType; if (Map.class.isAssignableFrom(rawType)) { // this is a Map so the second generic type is the value itemType = ObjectUtils.notNull((Class<?>) ((ParameterizedType) fieldType).getActualTypeArguments()[1]); } else if (List.class.isAssignableFrom(rawType)) { // this is a List so there is only a single generic type itemType = ObjectUtils.notNull((Class<?>) ((ParameterizedType) fieldType).getActualTypeArguments()[0]); } else { // non-collection itemType = rawType; } return itemType; |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/ConstraintBindingSupport.java | 113 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/ConstraintBindingSupport.java | 147 |
@NonNull IValueTargetedConstraintsBase constraints, @NonNull ISource source) { parseLet(constraintSet, constraints, source); // parse rules for (IConstraintBase ruleObj : constraints.getRules()) { if (ruleObj instanceof TargetedAllowedValuesConstraint) { IAllowedValuesConstraint constraint = newAllowedValues((TargetedAllowedValuesConstraint) ruleObj, source); constraintSet.addConstraint(constraint); } else if (ruleObj instanceof TargetedExpectConstraint) { IExpectConstraint constraint = newExpect((TargetedExpectConstraint) ruleObj, source); constraintSet.addConstraint(constraint); } else if (ruleObj instanceof TargetedIndexHasKeyConstraint) { IIndexHasKeyConstraint constraint = newIndexHasKey((TargetedIndexHasKeyConstraint) ruleObj, source); constraintSet.addConstraint(constraint); } else if (ruleObj instanceof TargetedMatchesConstraint) { IMatchesConstraint constraint = newMatches((TargetedMatchesConstraint) ruleObj, source); constraintSet.addConstraint(constraint); } |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionFieldGlobal.java | 60 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldInline.java | 81 |
this.properties = ModelSupport.parseProperties(ObjectUtils.requireNonNull(binding.getProps())); this.javaTypeAdapter = ModelSupport.dataType(binding.getAsType()); this.defaultValue = ModelSupport.defaultValue(binding.getDefault(), this.javaTypeAdapter); this.flagContainer = ObjectUtils.notNull(Lazy.lazy(() -> { JsonKey jsonKey = binding.getJsonKey(); return FlagContainerSupport.newFlagContainer( binding.getFlags(), bindingInstance, this, jsonKey == null ? null : jsonKey.getFlagRef()); })); this.valueConstraints = ObjectUtils.notNull(Lazy.lazy(() -> { IValueConstrained retval = new ValueConstraintSet(); FieldConstraints constraints = binding.getConstraint(); if (constraints != null) { ConstraintBindingSupport.parse(retval, constraints, module.getSource()); |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/AssemblyModelContainerSupport.java | 142 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/ChoiceModelContainerSupport.java | 115 |
addInstance(assembly, modelInstances, namedModelInstances, assemblyInstances); } else if (obj instanceof InlineDefineAssembly) { IAssemblyInstanceAbsolute assembly = new InstanceModelAssemblyInline( (InlineDefineAssembly) obj, objInstance, assemblyInlineDefinitionPosition.getAndIncrement(), parent, nodeItemFactory); addInstance(assembly, modelInstances, namedModelInstances, assemblyInstances); } else if (obj instanceof FieldReference) { IFieldInstanceAbsolute field = newInstance( (FieldReference) obj, objInstance, fieldReferencePosition.getAndIncrement(), parent); addInstance(field, modelInstances, namedModelInstances, fieldInstances); } else if (obj instanceof InlineDefineField) { IFieldInstanceAbsolute field = new InstanceModelFieldInline( (InlineDefineField) obj, objInstance, fieldInlineDefinitionPosition.getAndIncrement(), parent); addInstance(field, modelInstances, namedModelInstances, fieldInstances); } else if (obj instanceof AssemblyModel.Choice) { |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/AssemblyModelContainerSupport.java | 180 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/ChoiceModelContainerSupport.java | 140 |
addInstance(choiceGroup, modelInstances, choiceGroupInstances); } else { throw new UnsupportedOperationException(String.format("Unknown model instance class: %s", obj.getClass())); } }); this.modelInstances = modelInstances.isEmpty() ? CollectionUtil.emptyList() : CollectionUtil.unmodifiableList(modelInstances); this.namedModelInstances = namedModelInstances.isEmpty() ? CollectionUtil.emptyMap() : CollectionUtil.unmodifiableMap(namedModelInstances); this.fieldInstances = fieldInstances.isEmpty() ? CollectionUtil.emptyMap() : CollectionUtil.unmodifiableMap(fieldInstances); this.assemblyInstances = assemblyInstances.isEmpty() ? CollectionUtil.emptyMap() : CollectionUtil.unmodifiableMap(assemblyInstances); |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionFlagGlobal.java | 91 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java | 99 |
return ObjectUtils.notNull(valueConstraints.get()); } @Override public Map<IAttributable.Key, Set<String>> getProperties() { return properties; } @Override public IDataTypeAdapter<?> getJavaTypeAdapter() { return javaTypeAdapter; } @Override public Object getDefaultValue() { return defaultValue; } @Override public String getName() { return ObjectUtils.notNull(getBinding().getName()); } @Override public String getFormalName() { return getBinding().getFormalName(); } @Override public MarkupLine getDescription() { return getBinding().getDescription(); } @Override public ModuleScope getModuleScope() { |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/impl/ConstraintFactory.java | 247 |
gov/nist/secauto/metaschema/databind/model/impl/ConstraintFactory.java | 268 |
IIndexConstraint.Builder builder = IIndexConstraint.builder(constraint.name()); applyId(builder, constraint.id()); applyFormalName(builder, constraint.formalName()); applyDescription(builder, constraint.description()); builder .source(source) .level(constraint.level()); applyTarget(builder, constraint.target()); applyProperties(builder, constraint.properties()); applyMessage(builder, constraint.message()); applyRemarks(builder, constraint.remarks()); applyKeyFields(builder, source, constraint.keyFields()); return builder.build(); } @NonNull static IIndexHasKeyConstraint newIndexHasKeyConstraint( |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelAssembly.java | 77 |
gov/nist/secauto/metaschema/databind/model/IBoundInstanceModelFieldComplex.java | 36 |
handler.writeItemAssembly(item, this); } @Override default IBoundObject deepCopyItem(IBoundObject item, IBoundObject parentInstance) throws BindingException { return getDefinition().deepCopyItem(item, parentInstance); } @Override default Class<? extends IBoundObject> getBoundClass() { return getDefinition().getBoundClass(); } @Override default void callBeforeDeserialize(IBoundObject targetObject, IBoundObject parentObject) throws BindingException { getDefinition().callBeforeDeserialize(targetObject, parentObject); } @Override default void callAfterDeserialize(IBoundObject targetObject, IBoundObject parentObject) throws BindingException { getDefinition().callAfterDeserialize(targetObject, parentObject); } } |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/impl/ConstraintFactory.java | 228 |
gov/nist/secauto/metaschema/databind/model/impl/ConstraintFactory.java | 247 |
gov/nist/secauto/metaschema/databind/model/impl/ConstraintFactory.java | 268 |
IUniqueConstraint.Builder builder = IUniqueConstraint.builder(); applyId(builder, constraint.id()); applyFormalName(builder, constraint.formalName()); applyDescription(builder, constraint.description()); builder .source(source) .level(constraint.level()); applyTarget(builder, constraint.target()); applyProperties(builder, constraint.properties()); applyMessage(builder, constraint.message()); applyRemarks(builder, constraint.remarks()); applyKeyFields(builder, source, constraint.keyFields()); return builder.build(); } @NonNull static IIndexConstraint newIndexConstraint(@NonNull Index constraint, @NonNull ISource source) { |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelAssemblyInline.java | 102 |
gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelFieldInline.java | 73 |
@NonNull INodeItemFactory nodeItemFactory) { super(parent); this.binding = binding; this.properties = ModelSupport.parseProperties(ObjectUtils.requireNonNull(binding.getProps())); this.groupAs = ModelSupport.groupAs(binding.getGroupAs(), parent.getOwningDefinition().getContainingModule()); this.boundNodeItem = ObjectUtils.notNull( Lazy.lazy(() -> (IAssemblyNodeItem) ObjectUtils.notNull(getContainingDefinition().getSourceNodeItem()) .getModelItemsByName(bindingInstance.getXmlQName()) .get(position))); this.flagContainer = ObjectUtils.notNull(Lazy.lazy(() -> { |
File | Line |
---|---|
gov/nist/secauto/metaschema/databind/model/impl/InstanceFlagInline.java | 85 |
gov/nist/secauto/metaschema/databind/model/impl/InstanceModelFieldScalar.java | 133 |
ValueConstraints valueAnnotation = getAnnotation().valueConstraints(); ConstraintSupport.parse(valueAnnotation, module.getSource(), retval); return retval; })); this.properties = ObjectUtils.notNull( Lazy.lazy(() -> CollectionUtil.unmodifiableMap(ObjectUtils.notNull( Arrays.stream(annotation.properties()) .map(ModelUtil::toPropertyEntry) .collect( Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> v2, LinkedHashMap::new)))))); } |