2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ===================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.champ.model;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
26 import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
28 @JsonDeserialize(builder = ChampConnectionConstraint.Builder.class)
29 public final class ChampConnectionConstraint {
31 private final String sourceType;
32 private final String targetType;
33 private final ChampConnectionMultiplicity cardinality;
35 private ChampConnectionConstraint() {
36 throw new RuntimeException("Cannot call ConnectionConstraint() constructor");
39 private ChampConnectionConstraint(Builder builder) {
40 this.sourceType = builder.sourceType;
41 this.targetType = builder.targetType;
42 this.cardinality = builder.multiplicity;
45 public String getSourceType() { return sourceType; }
46 public String getTargetType() { return targetType; }
47 public ChampConnectionMultiplicity getMultiplicity() { return cardinality; }
49 @JsonPOJOBuilder(buildMethodName = "build", withPrefix = "")
50 public static class Builder {
51 private final String sourceType;
52 private final String targetType;
54 private ChampConnectionMultiplicity multiplicity = ChampConnectionMultiplicity.MANY;
56 public Builder(@JsonProperty("sourceType") String sourceType, @JsonProperty("targetType") String targetType) {
57 this.sourceType = sourceType;
58 this.targetType = targetType;
61 public Builder multiplicity(ChampConnectionMultiplicity multiplicity) {
62 this.multiplicity = multiplicity;
66 public ChampConnectionConstraint build() {
67 return new ChampConnectionConstraint(this);
72 public int hashCode() {
73 return 31 * (getSourceType().hashCode() + getTargetType().hashCode());
77 public boolean equals(Object o) {
78 if (o instanceof ChampConnectionConstraint) {
79 final ChampConnectionConstraint connConstraint = (ChampConnectionConstraint) o;
81 if (connConstraint.getSourceType().equals(getSourceType()) &&
82 connConstraint.getTargetType().equals(getTargetType()) &&
83 connConstraint.getMultiplicity().equals(getMultiplicity())) return true;
90 public String toString() {
91 return "{sourceType: " + getSourceType() +
92 ", targetType: " + getTargetType() +
93 ", multiplicity: " + getMultiplicity()