Feature uses features-parent as parent
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / mit / PolicyPropertyInfo.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
3  * 
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
7  */
8
9 package org.opendaylight.groupbasedpolicy.renderer.opflex.mit;
10
11 /**
12  * Class containing metadata used to describe
13  * properties contained by an OpFlex Managed Object
14  *
15  * @author tbachman
16  */
17 public interface PolicyPropertyInfo {
18
19     /**
20      * enum that represents possible Property types
21      *
22      * @author tbachman
23      */
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");
27
28         private final String type;
29
30         PropertyType(String type) {
31             this.type = type;
32         }
33
34         @Override
35         public String toString() {
36             return this.type;
37         }
38     }
39
40     /**
41      * enum that represents the possible cardinalities of a Property
42      *
43      * @author tbachman
44      */
45     static public enum PropertyCardinality {
46         SCALAR("scalar"), VECTOR("vector");
47
48         private final String cardinality;
49
50         PropertyCardinality(String cardinality) {
51             this.cardinality = cardinality;
52         }
53
54         @Override
55         public String toString() {
56             return this.cardinality;
57         }
58     }
59
60     /**
61      * The unique local ID assigned to this Property
62      *
63      * @author tbachman
64      */
65     static public class PolicyPropertyId {
66
67         private final long propertyId;
68
69         public PolicyPropertyId(long propertyId) {
70             this.propertyId = propertyId;
71         }
72
73         public long getPropertyId() {
74             return propertyId;
75         }
76
77         @Override
78         public int hashCode() {
79             final int prime = 31;
80             int result = 1;
81             result = prime * result + (int) (propertyId ^ (propertyId >>> 32));
82             return result;
83         }
84
85         @Override
86         public boolean equals(Object obj) {
87             if (this == obj)
88                 return true;
89             if (obj == null)
90                 return false;
91             if (getClass() != obj.getClass())
92                 return false;
93             PolicyPropertyId other = (PolicyPropertyId) obj;
94             if (propertyId != other.propertyId)
95                 return false;
96             return true;
97         }
98
99     }
100
101     public static class PolicyPropertyInfoBuilder {
102
103         private long classId;
104         private PropertyType type;
105         private PolicyPropertyId propId;
106         private PropertyCardinality propCardinality;
107         private String propName;
108         private EnumInfo enumInfo;
109
110         public PolicyPropertyInfoBuilder setClassId(long classId) {
111             this.classId = classId;
112             return this;
113         }
114
115         public PolicyPropertyInfoBuilder setType(PropertyType type) {
116             this.type = type;
117             return this;
118         }
119
120         public PolicyPropertyInfoBuilder setPropId(PolicyPropertyId propId) {
121             this.propId = propId;
122             return this;
123         }
124
125         public PolicyPropertyInfoBuilder setPropCardinality(PropertyCardinality propCardinality) {
126             this.propCardinality = propCardinality;
127             return this;
128         }
129
130         public PolicyPropertyInfoBuilder setPropName(String propName) {
131             this.propName = propName;
132             return this;
133         }
134
135         public PolicyPropertyInfoBuilder setEnumInfo(EnumInfo enumInfo) {
136             this.enumInfo = enumInfo;
137             return this;
138         }
139
140         public PolicyPropertyInfo build() {
141             return new PolicyPropertyInfoImpl(this);
142         }
143
144         private static final class PolicyPropertyInfoImpl implements PolicyPropertyInfo {
145
146             /*
147              * The classId is only used in COMPOSITE properties
148              */
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;
155
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;
163
164             }
165
166             @Override
167             public long getClassId() {
168                 return classId;
169             }
170
171             @Override
172             public PropertyType getType() {
173                 return type;
174             }
175
176             @Override
177             public PolicyPropertyId getPropId() {
178                 return propId;
179             }
180
181             @Override
182             public PropertyCardinality getPropCardinality() {
183                 return propCardinality;
184             }
185
186             @Override
187             public String getPropName() {
188                 return propName;
189             }
190
191             @Override
192             public EnumInfo getEnumInfo() {
193                 return enumInfo;
194             }
195         }
196
197     }
198
199     /**
200      * Get the class of the {@link PolicyPropertyInfo} object
201      *
202      * @return
203      */
204     public long getClassId();
205
206     /**
207      * Get the type of the {@link PolicyPropertyInfo} object
208      *
209      * @return
210      */
211     public PropertyType getType();
212
213     /**
214      * Get the ID of the {@link PolicyPropertyInfo} object
215      *
216      * @return
217      */
218     public PolicyPropertyId getPropId();
219
220     /**
221      * Get the cardinality of the {@link PolicyPropertyInfo} object
222      *
223      * @return
224      */
225     public PropertyCardinality getPropCardinality();
226
227     /**
228      * Get the name of the {@link PolicyPropertyInfo} object
229      *
230      * @return
231      */
232     public String getPropName();
233
234     /**
235      * Get the {@link EnumInfo} object for the {@link PolicyPropertyInfo} object, if present
236      *
237      * @return
238      */
239     public EnumInfo getEnumInfo();
240
241 }