CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
File |
Line |
gov/nist/secauto/oscal/lib/profile/resolver/alter/AddVisitor.java |
43 |
gov/nist/secauto/oscal/lib/profile/resolver/alter/RemoveVisitor.java |
41 |
PARAM("param", Parameter.class),
PART("part", ControlPart.class);
@NonNull
private static final Map<Class<?>, TargetType> CLASS_TO_TYPE;
@NonNull
private static final Map<String, TargetType> NAME_TO_TYPE;
@NonNull
private final String fieldName;
@NonNull
private final Class<?> clazz;
static {
{
Map<Class<?>, TargetType> map = new ConcurrentHashMap<>();
for (TargetType type : values()) {
map.put(type.getClazz(), type);
}
CLASS_TO_TYPE = CollectionUtil.unmodifiableMap(map);
}
{
Map<String, TargetType> map = new ConcurrentHashMap<>();
for (TargetType type : values()) {
map.put(type.fieldName(), type);
}
NAME_TO_TYPE = CollectionUtil.unmodifiableMap(map);
}
}
/**
* Get the target type associated with the provided {@code clazz}.
*
* @param clazz
* the class to identify the target type for
* @return the associated target type or {@code null} if the class is not
* associated with a target type
*/
@Nullable
public static TargetType forClass(@NonNull Class<?> clazz) {
Class<?> target = clazz;
TargetType retval;
// recurse over parent classes to find a match
do {
retval = CLASS_TO_TYPE.get(target);
} while (retval == null && (target = target.getSuperclass()) != null);
return retval;
}
/**
* Get the target type associated with the provided field {@code name}.
*
* @param name
* the field name to identify the target type for
* @return the associated target type or {@code null} if the name is not
* associated with a target type
*/
@Nullable
public static TargetType forFieldName(@Nullable String name) {
return name == null ? null : NAME_TO_TYPE.get(name);
}
TargetType(@NonNull String fieldName, @NonNull Class<?> clazz) {
this.fieldName = fieldName;
this.clazz = clazz;
}
/**
* Get the field name associated with the target type.
*
* @return the name
*/
public String fieldName() {
return fieldName;
}
/**
* Get the bound class associated with the target type.
*
* @return the class
*/
public Class<?> getClazz() {
return clazz;
}
} |
File |
Line |
gov/nist/secauto/oscal/lib/model/control/catalog/AbstractCatalogGroup.java |
29 |
gov/nist/secauto/oscal/lib/model/control/catalog/AbstractControl.java |
52 |
@NonNull
@Override
public Stream<String> getReferencedParameterIds() {
// get parameters referenced by the group's parts
Stream<String> insertIds = CollectionUtil.listOrEmpty(getParts()).stream()
// Get the full part hierarchy
.flatMap(part -> Stream.concat(Stream.of(part), part.getPartsRecursively()))
// Get the inserts for each part
.flatMap(part -> part.getInserts(insert -> "param".equals(insert.getType().toString())))
// Get the param ids for each insert
.map(insert -> insert.getIdReference().toString())
.flatMap(ObjectUtils::filterNull);
// get parameters referenced by the control's parameters
Stream<String> parameterIds = CollectionUtil.listOrEmpty(getParams()).stream()
.flatMap(ObjectUtils::filterNull)
.flatMap(AbstractParameter::getParameterReferences);
return ObjectUtils.notNull(
Stream.concat(insertIds, parameterIds).distinct());
}
@NonNull
public static Builder builder(@NonNull String id) {
return new Builder(id);
}
public static class Builder {
@NonNull
private final String id;
private String clazz;
private MarkupLine title;
private final List<Parameter> params = new LinkedList<>();
private final List<Property> props = new LinkedList<>();
private final List<Link> links = new LinkedList<>();
private final List<ControlPart> parts = new LinkedList<>();
private final List<CatalogGroup> groups = new LinkedList<>(); |
File |
Line |
gov/nist/secauto/oscal/lib/model/control/catalog/AbstractCatalogGroup.java |
130 |
gov/nist/secauto/oscal/lib/model/control/catalog/AbstractControl.java |
146 |
CatalogGroup retval = new CatalogGroup();
retval.setId(id);
if (title == null) {
throw new IllegalStateException("a title must be provided");
}
retval.setTitle(title);
if (clazz != null) {
retval.setClazz(clazz);
}
if (!params.isEmpty()) {
retval.setParams(params);
}
if (!props.isEmpty()) {
retval.setProps(props);
}
if (!links.isEmpty()) {
retval.setLinks(links);
}
if (!parts.isEmpty()) {
retval.setParts(parts);
}
if (!controls.isEmpty()) { |
File |
Line |
gov/nist/secauto/oscal/lib/metapath/function/library/HasOscalNamespace.java |
58 |
gov/nist/secauto/oscal/lib/metapath/function/library/HasOscalNamespace.java |
99 |
.namespace(OscalModelConstants.NS_OSCAL)
.argument(IArgument.builder()
.name("propOrPart")
.type(IAssemblyNodeItem.type())
.one()
.build())
.argument(IArgument.builder()
.name("namespace")
.type(IStringItem.type())
.oneOrMore()
.build())
.allowUnboundedArity(true)
.focusIndependent()
.contextIndependent()
.deterministic()
.returnType(IBooleanItem.type())
.returnOne()
.functionHandler(HasOscalNamespace::executeTwoArg)
.build(); |