diff options
author | 2020-04-30 10:41:46 -0400 | |
---|---|---|
committer | 2020-04-30 11:08:10 -0400 | |
commit | e7f7527a7ad0397f9f98c739f6f4dfba357bcf3a (patch) | |
tree | 96db50b73b0a7d096683ecb0672c79cf6897ee90 /graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java | |
parent | 0fdf096ae4ff4ee4b7a644549bd67d75e4aa82b1 (diff) |
add fluent type builder support to A&AI client
add fluent type builder support to A&AI client
Issue-ID: SO-2856
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I2957aedb84a1c6b23979ff2e1c4dfb16b3a646c7
Diffstat (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java')
-rw-r--r-- | graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java index 8045a220a3..b3402fa221 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java @@ -74,6 +74,7 @@ import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; import org.onap.aai.domain.yang.Vserver; import org.onap.aai.domain.yang.Zone; +import org.onap.aaiclient.client.aai.entities.uri.AAIFluentTypeReverseLookup; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType; import org.onap.so.constants.Defaults; import org.reflections.Reflections; @@ -262,12 +263,16 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S } protected AAIObjectType(String parentUri, String partialUri, String name) { + this(parentUri, partialUri, name, true); + } + + public AAIObjectType(String parentUri, String partialUri, String name, boolean register) { this.parentUri = parentUri; this.partialUri = partialUri; this.uriTemplate = parentUri + partialUri; this.aaiObjectClass = null; this.name = name; - if (!AAIObjectType.map.containsKey(name)) { + if (register && !AAIObjectType.map.containsKey(name)) { AAIObjectType.map.put(name, this); } } @@ -288,6 +293,11 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S return this.uriTemplate(); } + public static AAIObjectType fromTypeName(String name, String uri) { + + return new AAIFluentTypeReverseLookup().fromName(name, uri); + } + public static AAIObjectType fromTypeName(String name) { if (map.containsKey(name)) { return map.get(name); @@ -316,6 +326,21 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S return this.partialUri; } + @Override + public int hashCode() { + return this.typeName().hashCode(); + } + + @Override + public boolean equals(Object o) { + + if (o instanceof AAIObjectBase) { + return this.typeName().equals(((AAIObjectBase) o).typeName()); + } + + return false; + } + protected String removeParentUri(Class<?> aaiObjectClass, String parentUri) { return aaiObjectClass.getAnnotation(Metadata.class).uriTemplate().replaceFirst(Pattern.quote(parentUri), ""); } |