1
2
3
4
5
6 package gov.nist.secauto.oscal.lib.profile.resolver.support;
7
8 import gov.nist.secauto.metaschema.core.metapath.item.node.IModelNodeItem;
9 import gov.nist.secauto.oscal.lib.profile.resolver.support.IEntityItem.ItemType;
10
11 import edu.umd.cs.findbugs.annotations.NonNull;
12
13 public class ReassignmentIndexer
14 extends BasicIndexer {
15 @NonNull
16 private final IIdentifierMapper mapper;
17
18 public ReassignmentIndexer(@NonNull IIdentifierMapper mapper) {
19 this.mapper = mapper;
20 }
21
22 @NonNull
23 protected IIdentifierMapper getMapper() {
24 return mapper;
25 }
26
27 @Override
28 protected AbstractEntityItem.Builder newBuilder(
29 IModelNodeItem<?, ?> item,
30 ItemType itemType,
31 String identifier) {
32 AbstractEntityItem.Builder builder = super.newBuilder(item, itemType, identifier);
33
34 String reassignment = getMapper().mapByItemType(itemType, identifier);
35 if (!identifier.equals(reassignment)) {
36 builder.reassignedIdentifier(reassignment);
37 }
38 return builder;
39 }
40
41 @Override
42 public IEntityItem getEntity(ItemType itemType, String identifier, boolean normalize) {
43
44 String reassignment = getMapper().mapByItemType(itemType, identifier);
45
46 return super.getEntity(itemType, reassignment, normalize);
47 }
48 }