1
2
3
4
5
6 package gov.nist.secauto.oscal.lib.profile.resolver.support;
7
8 import edu.umd.cs.findbugs.annotations.NonNull;
9
10 public interface IIdentifierMapper {
11 @NonNull
12 IIdentifierMapper IDENTITY = new IIdentifierMapper() {
13
14 @Override
15 public String mapRoleIdentifier(@NonNull String identifier) {
16 return identifier;
17 }
18
19 @Override
20 public String mapControlIdentifier(@NonNull String identifier) {
21 return identifier;
22 }
23
24 @Override
25 public String mapGroupIdentifier(@NonNull String identifier) {
26 return identifier;
27 }
28
29 @Override
30 public String mapParameterIdentifier(@NonNull String identifier) {
31 return identifier;
32 }
33
34 @Override
35 public @NonNull
36 String mapPartIdentifier(@NonNull String identifier) {
37 return identifier;
38 }
39 };
40
41 @NonNull
42 String mapRoleIdentifier(@NonNull String identifier);
43
44 @NonNull
45 String mapControlIdentifier(@NonNull String identifier);
46
47 @NonNull
48 String mapGroupIdentifier(@NonNull String identifier);
49
50 @NonNull
51 String mapParameterIdentifier(@NonNull String identifier);
52
53 @NonNull
54 String mapPartIdentifier(@NonNull String identifier);
55
56 @NonNull
57 default String mapByItemType(
58 @NonNull IEntityItem.ItemType itemType,
59 @NonNull String identifier) {
60 String retval;
61 switch (itemType) {
62 case CONTROL:
63 retval = mapControlIdentifier(identifier);
64 break;
65 case GROUP:
66 retval = mapGroupIdentifier(identifier);
67 break;
68 case PARAMETER:
69 retval = mapParameterIdentifier(identifier);
70 break;
71 case PART:
72 retval = mapPartIdentifier(identifier);
73 break;
74 case ROLE:
75 retval = mapRoleIdentifier(identifier);
76 break;
77 case LOCATION:
78 case PARTY:
79 case RESOURCE:
80 retval = identifier;
81 break;
82 default:
83 throw new UnsupportedOperationException("Unsupported item type: " + itemType.name());
84 }
85 return retval;
86 }
87 }