|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | +package com.cloud.network.nicira; |
| 18 | + |
| 19 | +import java.io.Serializable; |
| 20 | +import java.util.List; |
| 21 | + |
| 22 | +import org.apache.commons.lang.builder.EqualsBuilder; |
| 23 | +import org.apache.commons.lang.builder.HashCodeBuilder; |
| 24 | +import org.apache.commons.lang.builder.ReflectionToStringBuilder; |
| 25 | +import org.apache.commons.lang.builder.ToStringStyle; |
| 26 | + |
| 27 | +@SuppressWarnings("serial") |
| 28 | +public abstract class AccessConfiguration<T extends AccessRule> implements Serializable { |
| 29 | + |
| 30 | + protected String displayName; |
| 31 | + protected List<T> logicalPortEgressRules; |
| 32 | + protected List<T> logicalPortIngressRules; |
| 33 | + protected List<NiciraNvpTag> tags; |
| 34 | + protected String uuid; |
| 35 | + protected String href; |
| 36 | + protected String schema; |
| 37 | + |
| 38 | + public String getDisplayName() { |
| 39 | + return displayName; |
| 40 | + } |
| 41 | + |
| 42 | + public void setDisplayName(final String displayName) { |
| 43 | + this.displayName = displayName; |
| 44 | + } |
| 45 | + |
| 46 | + public List<T> getLogicalPortEgressRules() { |
| 47 | + return logicalPortEgressRules; |
| 48 | + } |
| 49 | + |
| 50 | + public void setLogicalPortEgressRules(final List<T> logicalPortEgressRules) { |
| 51 | + this.logicalPortEgressRules = logicalPortEgressRules; |
| 52 | + } |
| 53 | + |
| 54 | + public List<T> getLogicalPortIngressRules() { |
| 55 | + return logicalPortIngressRules; |
| 56 | + } |
| 57 | + |
| 58 | + public void setLogicalPortIngressRules(final List<T> logicalPortIngressRules) { |
| 59 | + this.logicalPortIngressRules = logicalPortIngressRules; |
| 60 | + } |
| 61 | + |
| 62 | + public String getUuid() { |
| 63 | + return uuid; |
| 64 | + } |
| 65 | + |
| 66 | + public void setUuid(final String uuid) { |
| 67 | + this.uuid = uuid; |
| 68 | + } |
| 69 | + |
| 70 | + public String getHref() { |
| 71 | + return href; |
| 72 | + } |
| 73 | + |
| 74 | + public void setHref(final String href) { |
| 75 | + this.href = href; |
| 76 | + } |
| 77 | + |
| 78 | + public String getSchema() { |
| 79 | + return schema; |
| 80 | + } |
| 81 | + |
| 82 | + public void setSchema(final String schema) { |
| 83 | + this.schema = schema; |
| 84 | + } |
| 85 | + |
| 86 | + public List<NiciraNvpTag> getTags() { |
| 87 | + return tags; |
| 88 | + } |
| 89 | + |
| 90 | + public void setTags(final List<NiciraNvpTag> tags) { |
| 91 | + this.tags = tags; |
| 92 | + } |
| 93 | + |
| 94 | + @Override |
| 95 | + public String toString() { |
| 96 | + return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false); |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public int hashCode() { |
| 101 | + return new HashCodeBuilder(17, 31) |
| 102 | + .append(displayName).append(logicalPortEgressRules) |
| 103 | + .append(logicalPortIngressRules).append(tags) |
| 104 | + .append(uuid).append(href).append(schema) |
| 105 | + .toHashCode(); |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + @SuppressWarnings("unchecked") |
| 110 | + public boolean equals(final Object obj) { |
| 111 | + if (obj == null) { |
| 112 | + return false; |
| 113 | + } |
| 114 | + if (obj == this) { |
| 115 | + return true; |
| 116 | + } |
| 117 | + if (!(this.getClass().isInstance(obj))) { |
| 118 | + return false; |
| 119 | + } |
| 120 | + final AccessConfiguration<? extends AccessRule> another = |
| 121 | + (AccessConfiguration<? extends AccessRule>) obj; |
| 122 | + return new EqualsBuilder() |
| 123 | + .append(displayName, another.displayName) |
| 124 | + .append(uuid, another.uuid) |
| 125 | + .append(href, another.href) |
| 126 | + .append(schema, another.schema) |
| 127 | + .isEquals(); |
| 128 | + } |
| 129 | +} |
0 commit comments