2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.datamodel;
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Objects;
28 public class NameIdPair extends HashMap<String, Object> {
30 public static final String OPTIONS = "options";
31 public static final String NAME = "name";
32 public static final String ID = "id";
33 public static final String OWNER_ID = "ownerId";
35 public NameIdPair(String name, String id) {
39 public NameIdPair(String name, String id, String ownerId) {
43 if (!Objects.isNull(ownerId)) {
49 public NameIdPair(NameIdPair nameIdPair) {
53 public String getName() {
54 return get(NAME).toString();
57 public void setName(String name) {
58 super.put(NAME, name);
61 public String getId() {
62 return get(ID).toString();
65 public void setId(String id) {
69 public String getOwnerId() {
70 return get(OWNER_ID).toString();
73 public void setOwnerId(String ownerId) {
74 put(OWNER_ID, ownerId);
77 public Set<NameIdPairWrapper> getWrappedData() {
78 return (Set<NameIdPairWrapper>) super.get(OPTIONS);
81 public void setWrappedData(Set<NameIdPairWrapper> data) {
82 super.put(OPTIONS, data);
85 public void addWrappedData(NameIdPairWrapper nameIdPairWrapper) {
86 if (get(OPTIONS) == null) {
87 setWrappedData(new HashSet<>());
89 getWrappedData().add(nameIdPairWrapper);
93 public boolean equals(Object o) {
94 if (this == o) return true;
95 if (!(o instanceof NameIdPair)) return false;
96 NameIdPair that = (NameIdPair) o;
97 return Objects.equals(getId(), that.getId());
101 public int hashCode() {
102 return Objects.hash(getId());
105 public static final NameIdPair create(String name, String id) {
106 return new NameIdPair(name, id);