Fork me on GitHub

CPD Results

The following document contains the results of PMD's CPD 7.19.0.

Duplications

File Line
gov/nist/secauto/metaschema/core/model/IFeatureContainerModelAbsolute.java 40
gov/nist/secauto/metaschema/core/model/IFeatureContainerModelGrouped.java 45
return getModelContainer().getModelInstances();
  }

  @Override
  default NMI getNamedModelInstanceByName(Integer name) {
    return getModelContainer().getNamedModelInstanceMap().get(name);
  }

  @SuppressWarnings("null")
  @Override
  default Collection<NMI> getNamedModelInstances() {
    return getModelContainer().getNamedModelInstanceMap().values();
  }

  @Override
  default FI getFieldInstanceByName(Integer name) {
    return getModelContainer().getFieldInstanceMap().get(name);
  }

  @SuppressWarnings("null")
  @Override
  default Collection<FI> getFieldInstances() {
    return getModelContainer().getFieldInstanceMap().values();
  }

  @Override
  default AI getAssemblyInstanceByName(Integer name) {
    return getModelContainer().getAssemblyInstanceMap().get(name);
  }

  @SuppressWarnings("null")
  @Override
  default Collection<AI> getAssemblyInstances() {
    return getModelContainer().getAssemblyInstanceMap().values();
  }
}
File Line
gov/nist/secauto/metaschema/core/mdm/impl/AbstractDMFieldNodeItem.java 37
gov/nist/secauto/metaschema/core/mdm/impl/AbstractDMFlagNodeItem.java 35
protected AbstractDMFieldNodeItem(@NonNull IAnyAtomicItem value) {
    // only allow extending classes to create instances
    this.value = value;
  }

  @Override
  public IAnyAtomicItem toAtomicItem() {
    return value;
  }

  /**
   * Change the field's value to the provided value.
   *
   * @param value
   *          the new field value
   */
  public void setValue(@NonNull IAnyAtomicItem value) {
    this.value = getValueItemType().cast(value);
  }

  /**
   * Change the field's value to the provided value.
   * <p>
   * This method expects the provided value to align with the object type
   * supported by the underlying atomic type.
   *
   * @param value
   *          the new field value
   */
  public void setValue(@NonNull Object value) {
    this.value = getValueItemType().newItem(value);
  }

  @Override
  public String stringValue() {
    return toAtomicItem().asString();
  }

  @Override
  protected String getValueSignature() {
    return toAtomicItem().toSignature();
  }

  @Override
  public Collection<? extends List<? extends IModelNodeItem<?, ?>>> getModelItems() {
    // no model items
    return CollectionUtil.emptyList();
  }

  @Override
  public List<? extends IModelNodeItem<?, ?>> getModelItemsByName(IEnhancedQName name) {
    // no model items
    return CollectionUtil.emptyList();
  }

}
File Line
gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringAfter.java 55
gov/nist/secauto/metaschema/core/metapath/function/library/FnSubstringBefore.java 55
private FnSubstringAfter() {
    // disable construction
  }

  @SuppressWarnings("unused")
  @NonNull
  private static ISequence<IStringItem> executeTwoArg(
      @NonNull IFunction function,
      @NonNull List<ISequence<?>> arguments,
      @NonNull DynamicContext dynamicContext,
      IItem focus) {

    // From the XPath 3.1 specification:
    // If the value of $arg1 or $arg2 is the empty sequence, or contains only
    // ignorable collation units, it is interpreted as the zero-length string.
    IStringItem arg1 = arguments.get(0).isEmpty()
        ? IStringItem.valueOf("")
        : FunctionUtils.asType(ObjectUtils.notNull(arguments.get(0).getFirstItem(true)));
    IStringItem arg2 = arguments.get(1).isEmpty()
        ? IStringItem.valueOf("")
        : FunctionUtils.asType(ObjectUtils.notNull(arguments.get(1).getFirstItem(true)));

    return ISequence.of(IStringItem.valueOf(fnSubstringAfter(arg1.asString(), arg2.asString())));
File Line
gov/nist/secauto/metaschema/core/metapath/cst/math/IntegerDivision.java 58
gov/nist/secauto/metaschema/core/metapath/cst/math/Modulo.java 59
protected ISequence<? extends IIntegerItem> evaluate(DynamicContext dynamicContext, ISequence<?> focus) {
    IAnyAtomicItem leftItem = ISequence.of(getLeft().accept(dynamicContext, focus).atomize()).getFirstItem(true);
    IAnyAtomicItem rightItem = ISequence.of(getRight().accept(dynamicContext, focus).atomize()).getFirstItem(true);
    INumericItem dividend = leftItem == null ? null : FunctionUtils.castToNumeric(leftItem);
    INumericItem divisor = rightItem == null ? null : FunctionUtils.castToNumeric(rightItem);

    return resultOrEmpty(dividend, divisor);
  }

  /**
   * Get the whole number quotient result by dividing the dividend by the divisor.
   *
   * @param dividend
   *          the item to be divided
   * @param divisor
   *          the item to divide by
   * @return the quotient result or an empty {@link ISequence} if either item is
   *         {@code null}
   */
  @NonNull
  protected static ISequence<? extends IIntegerItem> resultOrEmpty(@Nullable INumericItem dividend,
File Line
gov/nist/secauto/metaschema/core/metapath/function/library/FnMatches.java 102
gov/nist/secauto/metaschema/core/metapath/function/library/FnTokenize.java 136
private static ISequence<IBooleanItem> executeThreeArg(
      @NonNull IFunction function,
      @NonNull List<ISequence<?>> arguments,
      @NonNull DynamicContext dynamicContext,
      IItem focus) {
    IStringItem input = FunctionUtils.asTypeOrNull(arguments.get(0).getFirstItem(true));
    IStringItem pattern = ObjectUtils.requireNonNull(FunctionUtils.asTypeOrNull(arguments.get(1).getFirstItem(true)));
    IStringItem flags = ObjectUtils.requireNonNull(FunctionUtils.asTypeOrNull(arguments.get(2).getFirstItem(true)));

    return execute(input, pattern, flags);
  }

  @NonNull
  private static ISequence<IBooleanItem> execute(
File Line
gov/nist/secauto/metaschema/core/metapath/cst/math/Division.java 72
gov/nist/secauto/metaschema/core/metapath/cst/math/Multiplication.java 84
return OperationFunctions.opNumericDivide(dividend, divisor);
  }

  @SuppressWarnings("PMD.UseConcurrentHashMap")
  @NonNull
  private static Map<
      Class<? extends IAnyAtomicItem>,
      Map<Class<? extends IAnyAtomicItem>, OperationStrategy>> generateStrategies() {
    Map<Class<? extends IAnyAtomicItem>, Map<Class<? extends IAnyAtomicItem>, OperationStrategy>> strategies
        = new LinkedHashMap<>();

    // IYearMonthDurationItem strategies
    Map<Class<? extends IAnyAtomicItem>, OperationStrategy> typeStrategies = new LinkedHashMap<>();
    typeStrategies.put(INumericItem.class,
        (dividend, divisor, dynamicContext) -> OperationFunctions.opDivideYearMonthDuration(
File Line
gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java 371
gov/nist/secauto/metaschema/core/model/constraint/DefaultConstraintValidator.java 504
IIndex index = IIndex.newInstance(constraint.getKeyFields());
    for (INodeItem item : targets) {
      assert item != null;
      if (item.hasValue()) {
        INodeItem oldItem = null;
        try {
          oldItem = index.put(item, IIndex.toKey(item, index.getKeyFields(), dynamicContext));
        } catch (IllegalArgumentException ex) {
          // throw by IIndex.toKey
          handleError(constraint, item, ex, dynamicContext);
        }
        try {
          if (oldItem == null) {
            handlePass(constraint, node, item, dynamicContext);
          } else {
            handler.handleIndexDuplicateKeyViolation(constraint, node, oldItem, item, dynamicContext);
File Line
gov/nist/secauto/metaschema/core/metapath/function/library/MapContains.java 32
gov/nist/secauto/metaschema/core/metapath/function/library/MapGet.java 32
@NonNull
  static final IFunction SIGNATURE = IFunction.builder()
      .name(NAME)
      .namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_MAP)
      .deterministic()
      .contextIndependent()
      .focusIndependent()
      .argument(IArgument.builder()
          .name("map")
          .type(IMapItem.type())
          .one()
          .build())
      .argument(IArgument.builder()
          .name("key")
          .type(IAnyAtomicItem.type())
          .one()
          .build())
      .returnType(IBooleanItem.type())