2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.opflex.mit;
13 * Class containing metadata used to describe
14 * properties contained by an OpFlex Managed Object
19 public interface PolicyPropertyInfo {
21 * enum that represents possible Property types
26 static public enum PropertyType {
27 COMPOSITE("composite"),
28 REFERENCE("reference"),
38 private final String type;
40 PropertyType(String type) {
45 public String toString() {
51 * enum that represents the possible cardinalities of a Property
56 static public enum PropertyCardinality {
60 private final String cardinality;
62 PropertyCardinality(String cardinality) {
63 this.cardinality = cardinality;
67 public String toString() {
68 return this.cardinality;
73 * The unique local ID assigned to this Property
78 static public class PolicyPropertyId {
79 private final long propertyId;
80 public PolicyPropertyId(long propertyId) {
81 this.propertyId = propertyId;
83 public long getPropertyId() {
87 public int hashCode() {
90 result = prime * result + (int) (propertyId ^ (propertyId >>> 32));
94 public boolean equals(Object obj) {
99 if (getClass() != obj.getClass())
101 PolicyPropertyId other = (PolicyPropertyId) obj;
102 if (propertyId != other.propertyId)
109 public static class PolicyPropertyInfoBuilder {
110 private long classId;
111 private PropertyType type;
112 private PolicyPropertyId propId;
113 private PropertyCardinality propCardinality;
114 private String propName;
115 private EnumInfo enumInfo;
117 public PolicyPropertyInfoBuilder setClassId(long classId) {
118 this.classId = classId;
122 public PolicyPropertyInfoBuilder setType(PropertyType type) {
127 public PolicyPropertyInfoBuilder setPropId(PolicyPropertyId propId) {
128 this.propId = propId;
132 public PolicyPropertyInfoBuilder setPropCardinality(PropertyCardinality propCardinality) {
133 this.propCardinality = propCardinality;
137 public PolicyPropertyInfoBuilder setPropName(String propName) {
138 this.propName = propName;
142 public PolicyPropertyInfoBuilder setEnumInfo(EnumInfo enumInfo) {
143 this.enumInfo = enumInfo;
147 public PolicyPropertyInfo build() {
148 return new PolicyPropertyInfoImpl(this);
151 private static final class PolicyPropertyInfoImpl implements PolicyPropertyInfo {
153 * The classId is only used in COMPOSITE properties
155 private final long classId;
156 private final PropertyType type;
157 private final PolicyPropertyId propId;
158 private final PropertyCardinality propCardinality;
159 private final String propName;
160 private final EnumInfo enumInfo;
162 public PolicyPropertyInfoImpl(PolicyPropertyInfoBuilder builder) {
163 this.classId = builder.classId;
164 this.type = builder.type;
165 this.propId = builder.propId;
166 this.propCardinality = builder.propCardinality;
167 this.propName = builder.propName;
168 this.enumInfo = builder.enumInfo;
172 public long getClassId() {
177 public PropertyType getType() {
182 public PolicyPropertyId getPropId() {
187 public PropertyCardinality getPropCardinality() {
188 return propCardinality;
192 public String getPropName() {
197 public EnumInfo getEnumInfo() {
205 * Get the class of the {@link PolicyPropertyInfo} object
209 public long getClassId();
212 * Get the type of the {@link PolicyPropertyInfo} object
216 public PropertyType getType();
219 * Get the ID of the {@link PolicyPropertyInfo} object
223 public PolicyPropertyId getPropId();
226 * Get the cardinality of the {@link PolicyPropertyInfo} object
230 public PropertyCardinality getPropCardinality();
233 * Get the name of the {@link PolicyPropertyInfo} object
237 public String getPropName();
240 * Get the {@link EnumInfo} object for the {@link PolicyPropertyInfo}
245 public EnumInfo getEnumInfo();