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;
12 * Class containing metadata used to describe
13 * properties contained by an OpFlex Managed Object
17 public interface PolicyPropertyInfo {
20 * enum that represents possible Property types
24 static public enum PropertyType {
25 COMPOSITE("composite"), REFERENCE("reference"), STRING("string"), S64("s64"), U64("u64"), MAC("mac"), ENUM8(
26 "enum8"), ENUM16("enum16"), ENUM32("enum32"), ENUM64("enum64");
28 private final String type;
30 PropertyType(String type) {
35 public String toString() {
41 * enum that represents the possible cardinalities of a Property
45 static public enum PropertyCardinality {
46 SCALAR("scalar"), VECTOR("vector");
48 private final String cardinality;
50 PropertyCardinality(String cardinality) {
51 this.cardinality = cardinality;
55 public String toString() {
56 return this.cardinality;
61 * The unique local ID assigned to this Property
65 static public class PolicyPropertyId {
67 private final long propertyId;
69 public PolicyPropertyId(long propertyId) {
70 this.propertyId = propertyId;
73 public long getPropertyId() {
78 public int hashCode() {
81 result = prime * result + (int) (propertyId ^ (propertyId >>> 32));
86 public boolean equals(Object obj) {
91 if (getClass() != obj.getClass())
93 PolicyPropertyId other = (PolicyPropertyId) obj;
94 if (propertyId != other.propertyId)
101 public static class PolicyPropertyInfoBuilder {
103 private long classId;
104 private PropertyType type;
105 private PolicyPropertyId propId;
106 private PropertyCardinality propCardinality;
107 private String propName;
108 private EnumInfo enumInfo;
110 public PolicyPropertyInfoBuilder setClassId(long classId) {
111 this.classId = classId;
115 public PolicyPropertyInfoBuilder setType(PropertyType type) {
120 public PolicyPropertyInfoBuilder setPropId(PolicyPropertyId propId) {
121 this.propId = propId;
125 public PolicyPropertyInfoBuilder setPropCardinality(PropertyCardinality propCardinality) {
126 this.propCardinality = propCardinality;
130 public PolicyPropertyInfoBuilder setPropName(String propName) {
131 this.propName = propName;
135 public PolicyPropertyInfoBuilder setEnumInfo(EnumInfo enumInfo) {
136 this.enumInfo = enumInfo;
140 public PolicyPropertyInfo build() {
141 return new PolicyPropertyInfoImpl(this);
144 private static final class PolicyPropertyInfoImpl implements PolicyPropertyInfo {
147 * The classId is only used in COMPOSITE properties
149 private final long classId;
150 private final PropertyType type;
151 private final PolicyPropertyId propId;
152 private final PropertyCardinality propCardinality;
153 private final String propName;
154 private final EnumInfo enumInfo;
156 public PolicyPropertyInfoImpl(PolicyPropertyInfoBuilder builder) {
157 this.classId = builder.classId;
158 this.type = builder.type;
159 this.propId = builder.propId;
160 this.propCardinality = builder.propCardinality;
161 this.propName = builder.propName;
162 this.enumInfo = builder.enumInfo;
167 public long getClassId() {
172 public PropertyType getType() {
177 public PolicyPropertyId getPropId() {
182 public PropertyCardinality getPropCardinality() {
183 return propCardinality;
187 public String getPropName() {
192 public EnumInfo getEnumInfo() {
200 * Get the class of the {@link PolicyPropertyInfo} object
204 public long getClassId();
207 * Get the type of the {@link PolicyPropertyInfo} object
211 public PropertyType getType();
214 * Get the ID of the {@link PolicyPropertyInfo} object
218 public PolicyPropertyId getPropId();
221 * Get the cardinality of the {@link PolicyPropertyInfo} object
225 public PropertyCardinality getPropCardinality();
228 * Get the name of the {@link PolicyPropertyInfo} object
232 public String getPropName();
235 * Get the {@link EnumInfo} object for the {@link PolicyPropertyInfo} object, if present
239 public EnumInfo getEnumInfo();