aboutsummaryrefslogtreecommitdiffstats
path: root/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java
blob: 5b68d0c69ad0b1c3d350a2d08ce5d9f4f4cbffb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.aaiclient.client.aai;

import java.io.Serializable;
import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals;
import org.onap.so.constants.Defaults;
import com.google.common.base.CaseFormat;

public class AAIObjectPlurals implements AAIObjectBase, GraphInventoryObjectPlurals, Serializable {

    private static final long serialVersionUID = 5312713297525740746L;

    public static final AAIObjectPlurals CUSTOMER =
            new AAIObjectPlurals(AAIObjectType.CUSTOMER, AAINamespaceConstants.BUSINESS, "/customers");
    public static final AAIObjectPlurals GENERIC_VNF =
            new AAIObjectPlurals(AAIObjectType.GENERIC_VNF, AAINamespaceConstants.NETWORK, "/generic-vnfs");
    public static final AAIObjectPlurals PORT_GROUP =
            new AAIObjectPlurals(AAIObjectType.PORT_GROUP, AAIObjectType.VCE.uriTemplate(), "/port-groups");
    public static final AAIObjectPlurals PSERVER =
            new AAIObjectPlurals(AAIObjectType.PSERVER, AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers");
    public static final AAIObjectPlurals P_INTERFACE =
            new AAIObjectPlurals(AAIObjectType.P_INTERFACE, AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces");
    public static final AAIObjectPlurals L3_NETWORK =
            new AAIObjectPlurals(AAIObjectType.L3_NETWORK, AAINamespaceConstants.NETWORK, "/l3-networks");
    public static final AAIObjectPlurals NETWORK_POLICY =
            new AAIObjectPlurals(AAIObjectType.NETWORK_POLICY, AAINamespaceConstants.NETWORK, "/network-policies");
    public static final AAIObjectPlurals VPN_BINDING =
            new AAIObjectPlurals(AAIObjectType.VPN_BINDING, AAINamespaceConstants.NETWORK, "/vpn-bindings");
    public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals(AAIObjectType.SERVICE_SUBSCRIPTION,
            AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions");
    public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals(AAIObjectType.SERVICE_INSTANCE,
            AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances");
    public static final AAIObjectPlurals OWNING_ENTITY =
            new AAIObjectPlurals(AAIObjectType.OWNING_ENTITY, AAINamespaceConstants.BUSINESS, "/owning-entities");
    public static final AAIObjectPlurals VOLUME_GROUP = new AAIObjectPlurals(AAIObjectType.VOLUME_GROUP,
            AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups");
    public static final AAIObjectPlurals AVAILIBILITY_ZONE = new AAIObjectPlurals(AAIObjectType.AVAILIBILITY_ZONE,
            AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones");
    public static final AAIObjectPlurals VF_MODULE =
            new AAIObjectPlurals(AAIObjectType.VF_MODULE, AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules");
    public static final AAIObjectPlurals CONFIGURATION =
            new AAIObjectPlurals(AAIObjectType.CONFIGURATION, AAINamespaceConstants.NETWORK, "/configurations");
    public static final AAIObjectPlurals DEFAULT_TENANT =
            new AAIObjectPlurals(AAIObjectType.DEFAULT_TENANT, AAINamespaceConstants.CLOUD_INFRASTRUCTURE
                    + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants");
    public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals(AAIObjectType.NETWORK_TECHNOLOGY,
            AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies");
    public static final AAIObjectPlurals LOGICAL_LINK =
            new AAIObjectPlurals(AAIObjectType.LOGICAL_LINK, AAINamespaceConstants.NETWORK, "/logical-links");
    public static final AAIObjectPlurals L_INTERFACE =
            new AAIObjectPlurals(AAIObjectType.L_INTERFACE, AAIObjectType.VSERVER.uriTemplate(), "/l-interfaces");
    public static final AAIObjectPlurals SUB_L_INTERFACE =
            new AAIObjectPlurals(AAIObjectType.L_INTERFACE, AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces");
    public static final AAIObjectPlurals INSTANCE_GROUP =
            new AAIObjectPlurals(AAIObjectType.INSTANCE_GROUP, AAINamespaceConstants.NETWORK, "/instance-groups");
    public static final AAIObjectPlurals PNF =
            new AAIObjectPlurals(AAIObjectType.PNF, AAINamespaceConstants.NETWORK, "/pnfs");

    private final String uriTemplate;
    private final String partialUri;
    private final String name;

    protected AAIObjectPlurals(AAIObjectType type, String parentUri, String partialUri) {
        this.uriTemplate = parentUri + partialUri;
        this.partialUri = partialUri;
        this.name = type.typeName();
    }

    public AAIObjectPlurals(String name, String parentUri, String partialUri) {
        this.uriTemplate = parentUri + partialUri;
        this.partialUri = partialUri;
        this.name = name;
    }

    @Override
    public String toString() {
        return this.uriTemplate();
    }

    @Override
    public String uriTemplate() {
        return this.uriTemplate;
    }

    @Override
    public String partialUri() {
        return this.partialUri;
    }

    @Override
    public String typeName() {
        return this.typeName(CaseFormat.LOWER_HYPHEN);
    }

    @Override
    public String typeName(CaseFormat format) {
        return CaseFormat.LOWER_HYPHEN.to(format, this.name.replace("default-", ""));
    }

    @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;
    }
}