Feature uses features-parent as parent
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / mit / PolicyObjectInstance.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 package org.opendaylight.groupbasedpolicy.renderer.opflex.mit;
9
10 import java.math.BigInteger;
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
14 import java.util.Map;
15
16 import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
19
20 /**
21  * This is a policy object instance, used to provide an abstraction
22  * between OpFlex messaging and the back-end policy.
23  *
24  * @author tbachman
25  */
26 public class PolicyObjectInstance {
27
28     /**
29      * An object used as a key for the property hash map. It
30      * consists of the tuple: { {@link PolicyPropertyId}, {@link PolicyPropertyInfo.PropertyType},
31      * {@link PolicyPropertyInfo.PropertyCardinality}
32      *
33      * @author tbachman
34      */
35     public static class PropertyKey {
36
37         private final PolicyPropertyId propId;
38         private final PolicyPropertyInfo.PropertyType type;
39         private final PolicyPropertyInfo.PropertyCardinality cardinality;
40
41         public PropertyKey(PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type,
42                 PolicyPropertyInfo.PropertyCardinality cardinality) {
43             this.propId = propId;
44             this.type = type;
45             this.cardinality = cardinality;
46         }
47
48         @Override
49         public int hashCode() {
50             final int prime = 31;
51             int result = 1;
52             result = prime * result + ((cardinality == null) ? 0 : cardinality.hashCode());
53             result = prime * result + ((propId == null) ? 0 : propId.hashCode());
54             result = prime * result + ((type == null) ? 0 : type.hashCode());
55             return result;
56         }
57
58         @Override
59         public boolean equals(Object obj) {
60             if (this == obj)
61                 return true;
62             if (obj == null)
63                 return false;
64             if (getClass() != obj.getClass())
65                 return false;
66             PropertyKey other = (PropertyKey) obj;
67             if (cardinality != other.cardinality)
68                 return false;
69             if (propId == null) {
70                 if (other.propId != null)
71                     return false;
72             } else if (!propId.equals(other.propId))
73                 return false;
74             if (type != other.type)
75                 return false;
76             return true;
77         }
78
79     }
80
81     /**
82      * Class that contains a value held by the {@link PolicyObjectInstance}.
83      * The value can be scalar or vector in nature.
84      *
85      * @author tbachman
86      */
87     public static class Value {
88
89         private Object v;
90         private List<Object> vl;
91         private PolicyPropertyInfo.PropertyType type;
92         private PolicyPropertyInfo.PropertyCardinality cardinality;
93
94         public void setPropertyType(PolicyPropertyInfo.PropertyType type) {
95             this.type = type;
96         }
97
98         public void setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality cardinality) {
99             this.cardinality = cardinality;
100         }
101
102         public void setValue(Object v) {
103             this.v = v;
104         }
105
106         public void setValue(List<Object> vl) {
107             this.vl = vl;
108         }
109
110         public Object getValue(int index) {
111             if (this.cardinality == PolicyPropertyInfo.PropertyCardinality.VECTOR) {
112                 return this.vl.get(index);
113             } else {
114                 return this.v;
115             }
116         }
117
118         public PolicyPropertyInfo.PropertyType getType() {
119             return this.type;
120         }
121     }
122
123     /**
124      * Class used as a reference to another PolicyObject.
125      *
126      * @author tbachman
127      */
128     public static class PolicyReference {
129
130         private final Uri uri;
131         private final long classId;
132
133         public PolicyReference(long classId, Uri uri) {
134             this.uri = uri;
135             this.classId = classId;
136         }
137
138         public Uri getUri() {
139             return this.uri;
140         }
141
142         public long getClassId() {
143             return this.classId;
144         }
145
146         @Override
147         public int hashCode() {
148             final int prime = 31;
149             int result = 1;
150             result = prime * result + (int) (classId ^ (classId >>> 32));
151             result = prime * result + ((uri == null) ? 0 : uri.hashCode());
152             return result;
153         }
154
155         @Override
156         public boolean equals(Object obj) {
157             if (this == obj)
158                 return true;
159             if (obj == null)
160                 return false;
161             if (getClass() != obj.getClass())
162                 return false;
163             PolicyReference other = (PolicyReference) obj;
164             if (classId != other.classId)
165                 return false;
166             if (uri == null) {
167                 if (other.uri != null)
168                     return false;
169             } else if (!uri.equals(other.uri))
170                 return false;
171             return true;
172         }
173
174     }
175
176     private final long classId;
177     private Uri uri;
178     private Uri parentUri;
179     private String parentSubject;
180     private String parentRelation;
181     private final List<Uri> children = new ArrayList<>();
182     private final Map<PropertyKey, Value> propertyMap = new HashMap<>();
183
184     private PolicyPropertyInfo.PropertyType normalize(PolicyPropertyInfo.PropertyType type) {
185         switch (type) {
186             case ENUM8:
187             case ENUM16:
188             case ENUM32:
189             case ENUM64:
190                 return PolicyPropertyInfo.PropertyType.U64;
191             default:
192                 return type;
193         }
194     }
195
196     public PolicyObjectInstance(long classId) {
197         this.classId = classId;
198     }
199
200     /**
201      * Get the class ID for this object instance.
202      *
203      * @return the class ID
204      */
205     public long getClassId() {
206         return this.classId;
207     }
208
209     public Uri getUri() {
210         return uri;
211     }
212
213     public void setUri(Uri uri) {
214         this.uri = uri;
215     }
216
217     public void addChild(Uri childUri) {
218         children.add(childUri);
219     }
220
221     public List<Uri> getChildren() {
222         return this.children;
223     }
224
225     public void setParent(Uri uri) {
226         this.parentUri = uri;
227     }
228
229     public Uri getParent() {
230         return this.parentUri;
231     }
232
233     public void setParentSubject(String subject) {
234         this.parentSubject = subject;
235     }
236
237     public String getParentSubject() {
238         return this.parentSubject;
239     }
240
241     public void setParentRelation(String relation) {
242         this.parentRelation = relation;
243     }
244
245     public String getParentRelation() {
246         return this.parentRelation;
247     }
248
249     /**
250      * Check whether the given property is set. If the property is
251      * vector-valued, this will return false if the vector is zero length
252      *
253      * @param propId
254      * @param type
255      * @param cardinality
256      * @return true if set, false if not set or zero length vector
257      */
258     public boolean isSet(PolicyPropertyInfo.PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type,
259             PolicyPropertyInfo.PropertyCardinality cardinality) {
260         type = normalize(type);
261         PropertyKey key = new PropertyKey(propId, type, cardinality);
262         return propertyMap.containsKey(key);
263     }
264
265     /**
266      * Unset the given property. If it's a vector, the vector is
267      * emptied. If its a scalar, the scalar is unset.
268      *
269      * @param propId
270      * @param type
271      * @param cardinality
272      * @return true if the property was alread set before
273      */
274     public boolean unset(PolicyPropertyInfo.PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type,
275             PolicyPropertyInfo.PropertyCardinality cardinality) {
276         type = normalize(type);
277         PropertyKey key = new PropertyKey(propId, type, cardinality);
278         Value v = propertyMap.remove(key);
279         if (v == null)
280             return false;
281         return true;
282     }
283
284     // getters
285
286     /**
287      * Get the unsigned 64-bit valued property for prop_name.
288      *
289      * @param id
290      * @return null if not present or {@link BigInteger}
291      */
292     public BigInteger getUint64(PolicyPropertyInfo.PolicyPropertyId id) {
293         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64,
294                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
295         return (BigInteger) propertyMap.get(key).getValue(0);
296     }
297
298     /**
299      * For a vector-valued 64-bit unsigned property, get the specified
300      * property value at the specified index
301      *
302      * @param id
303      * @param index
304      * @return the property value
305      */
306     public BigInteger getUint64(PolicyPropertyInfo.PolicyPropertyId id, int index) {
307         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64,
308                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
309         return (BigInteger) propertyMap.get(key).getValue(index);
310     }
311
312     /**
313      * Get the number of unsigned 64-bit values for the specified
314      * property
315      *
316      * @param id
317      * @return the number of elements
318      */
319     public int getUint64Size(PolicyPropertyInfo.PolicyPropertyId id) {
320         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64,
321                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
322         Value v = propertyMap.get(key);
323         return v.vl.size();
324     }
325
326     /**
327      * Get the signed 64-bit valued property for prop_name.
328      *
329      * @param id
330      * @return the property value
331      */
332     public long getInt64(PolicyPropertyInfo.PolicyPropertyId id) {
333         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64,
334                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
335         return (long) propertyMap.get(key).getValue(0);
336     }
337
338     /**
339      * For a vector-valued 64-bit signed property, get the specified
340      * property value at the specified index
341      *
342      * @param id
343      * @param index
344      * @return the property value
345      */
346     public long getInt64(PolicyPropertyInfo.PolicyPropertyId id, int index) {
347         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64,
348                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
349         return (long) propertyMap.get(key).getValue(index);
350     }
351
352     /**
353      * Get the number of signed 64-bit values for the specified
354      * property
355      *
356      * @param id
357      * @return the number of elements
358      */
359     public int getInt64Size(PolicyPropertyInfo.PolicyPropertyId id) {
360         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64,
361                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
362         Value v = propertyMap.get(key);
363         return v.vl.size();
364     }
365
366     /**
367      * Get the string-valued property for prop_name.
368      *
369      * @param id
370      * @return the property value
371      */
372     public String getString(PolicyPropertyInfo.PolicyPropertyId id) {
373         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING,
374                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
375         return (String) propertyMap.get(key).getValue(0);
376     }
377
378     /**
379      * For a vector-valued string property, get the specified property
380      * value at the specified index
381      *
382      * @param id
383      * @param index
384      * @return the property value
385      */
386     public String getString(PolicyPropertyInfo.PolicyPropertyId id, int index) {
387         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING,
388                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
389         return (String) propertyMap.get(key).getValue(index);
390     }
391
392     /**
393      * Get the number of string values for the specified property
394      *
395      * @param id
396      * @return the number of elements
397      */
398     public int getStringSize(PolicyPropertyInfo.PolicyPropertyId id) {
399         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING,
400                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
401         Value v = propertyMap.get(key);
402         return v.vl.size();
403     }
404
405     /**
406      * Get the reference-valued property for prop_name.
407      * 
408      * @param id
409      * @return the property value
410      */
411     public PolicyReference getReference(PolicyPropertyInfo.PolicyPropertyId id) {
412         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE,
413                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
414         return (PolicyReference) propertyMap.get(key).getValue(0);
415     }
416
417     /**
418      * For a vector-valued reference property, get the specified property
419      * value at the specified index
420      *
421      * @param id
422      * @param index
423      * @return the property value
424      */
425     public PolicyReference getReference(PolicyPropertyInfo.PolicyPropertyId id, int index) {
426         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE,
427                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
428         return (PolicyReference) propertyMap.get(key).getValue(index);
429     }
430
431     /**
432      * Get the number of reference values for the specified property
433      *
434      * @param id
435      * @return the number of elements
436      */
437     public int getReferenceSize(PolicyPropertyInfo.PolicyPropertyId id) {
438         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE,
439                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
440         Value v = propertyMap.get(key);
441         return v.vl.size();
442     }
443
444     /**
445      * Get the MAC-address-valued property for prop_name.
446      *
447      * @param id
448      * @return the property value
449      */
450     public MacAddress getMacAddress(PolicyPropertyInfo.PolicyPropertyId id) {
451         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC,
452                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
453         return (MacAddress) propertyMap.get(key).getValue(0);
454     }
455
456     /**
457      * For a vector-valued MAC address property, get the specified
458      * property value at the specified index
459      *
460      * @param id
461      * @param index
462      * @return the property value
463      */
464     public MacAddress getMacAddress(PolicyPropertyInfo.PolicyPropertyId id, int index) {
465         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC,
466                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
467         return (MacAddress) propertyMap.get(key).getValue(index);
468     }
469
470     /**
471      * Get the number of MAC address values for the specified
472      * property
473      *
474      * @param id
475      * @return the number of elements
476      */
477     public int getMacAddressSize(PolicyPropertyInfo.PolicyPropertyId id) {
478         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC,
479                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
480         Value v = propertyMap.get(key);
481         return v.vl.size();
482     }
483
484     // setters
485     /**
486      * Set the uint64-valued parameter to the specified value.
487      *
488      * @param id
489      * @param bi
490      */
491     public void setUint64(PolicyPropertyInfo.PolicyPropertyId id, BigInteger bi) {
492         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64,
493                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
494         Value v = propertyMap.get(key);
495         if (v == null)
496             v = new Value();
497         propertyMap.put(key, v);
498
499         v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
500         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
501         v.setValue(bi);
502     }
503
504     /**
505      * Set the uint64-vector-valued parameter to the specified value.
506      *
507      * @param id
508      * @param bil
509      */
510     public void setUint64(PolicyPropertyInfo.PolicyPropertyId id, List<BigInteger> bil) {
511         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64,
512                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
513         Value v = propertyMap.get(key);
514         if (v == null)
515             v = new Value();
516         propertyMap.put(key, v);
517
518         v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
519         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
520         v.setValue(bil);
521
522     }
523
524     /**
525      * Set the int64-valued parameter to the specified value.
526      *
527      * @param id
528      * @param li
529      */
530     public void setInt64(PolicyPropertyInfo.PolicyPropertyId id, long li) {
531         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64,
532                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
533         Value v = propertyMap.get(key);
534         if (v == null)
535             v = new Value();
536         propertyMap.put(key, v);
537
538         v.setPropertyType(PolicyPropertyInfo.PropertyType.S64);
539         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
540         v.setValue(li);
541
542     }
543
544     /**
545      * Set the int64-vector-valued parameter to the specified value.
546      *
547      * @param id
548      * @param ll
549      */
550     public void setInt64(PolicyPropertyInfo.PolicyPropertyId id, List<Long> ll) {
551         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64,
552                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
553         Value v = propertyMap.get(key);
554         if (v == null)
555             v = new Value();
556         propertyMap.put(key, v);
557
558         v.setPropertyType(PolicyPropertyInfo.PropertyType.S64);
559         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
560         v.setValue(ll);
561
562     }
563
564     /**
565      * Set the string-valued parameter to the specified value.
566      *
567      * @param id
568      * @param s
569      */
570     public void setString(PolicyPropertyInfo.PolicyPropertyId id, String s) {
571         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING,
572                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
573         Value v = propertyMap.get(key);
574         if (v == null)
575             v = new Value();
576         propertyMap.put(key, v);
577
578         v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING);
579         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
580         v.setValue(s);
581
582     }
583
584     /**
585      * Set the string-vector-valued parameter to the specified vector.
586      *
587      * @param id
588      * @param sl
589      */
590     public void setString(PolicyPropertyInfo.PolicyPropertyId id, List<String> sl) {
591         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING,
592                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
593         Value v = propertyMap.get(key);
594         if (v == null)
595             v = new Value();
596         propertyMap.put(key, v);
597
598         v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING);
599         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
600         v.setValue(sl);
601
602     }
603
604     /**
605      * Set the reference-valued parameter to the specified value.
606      *
607      * @param id
608      * @param pr
609      */
610     public void setReference(PolicyPropertyInfo.PolicyPropertyId id, PolicyReference pr) {
611         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE,
612                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
613         Value v = propertyMap.get(key);
614         if (v == null)
615             v = new Value();
616         propertyMap.put(key, v);
617
618         v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE);
619         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
620         v.setValue(pr);
621
622     }
623
624     /**
625      * Set the reference-vector-valued parameter to the specified
626      * vector.
627      *
628      * @param id
629      * @param prl
630      */
631     public void setReference(PolicyPropertyInfo.PolicyPropertyId id, List<PolicyReference> prl) {
632         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE,
633                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
634         Value v = propertyMap.get(key);
635         if (v == null)
636             v = new Value();
637         propertyMap.put(key, v);
638
639         v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE);
640         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
641         v.setValue(prl);
642
643     }
644
645     /**
646      * Set the MAC address-valued parameter to the specified value.
647      *
648      * @param id
649      * @param mac
650      */
651     public void setMacAddress(PolicyPropertyInfo.PolicyPropertyId id, MacAddress mac) {
652         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC,
653                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
654         Value v = propertyMap.get(key);
655         if (v == null)
656             v = new Value();
657         propertyMap.put(key, v);
658
659         v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC);
660         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
661         v.setValue(mac);
662
663     }
664
665     /**
666      * Set the MAC address-vector-valued parameter to the specified value.
667      *
668      * @param id
669      * @param macList
670      */
671     public void setMacAddress(PolicyPropertyInfo.PolicyPropertyId id, List<MacAddress> macList) {
672         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC,
673                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
674         Value v = propertyMap.get(key);
675         if (v == null)
676             v = new Value();
677         propertyMap.put(key, v);
678
679         v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC);
680         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
681         v.setValue(macList);
682
683     }
684
685     /**
686      * Add a value to a the specified unsigned 64-bit vector.
687      *
688      * @param id
689      * @param bi
690      */
691     public void addUint64(PolicyPropertyInfo.PolicyPropertyId id, BigInteger bi) {
692         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64,
693                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
694         Value v = propertyMap.get(key);
695         if (v == null) {
696             v = new Value();
697             v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
698             v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
699             List<BigInteger> bil = new ArrayList<BigInteger>();
700             v.setValue(bil);
701             propertyMap.put(key, v);
702         }
703         v.vl.add(bi);
704     }
705
706     /**
707      * Add a value to a the specified signed 64-bit vector.
708      *
709      * @param id
710      * @param li
711      */
712     public void addInt64(PolicyPropertyInfo.PolicyPropertyId id, long li) {
713         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64,
714                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
715         Value v = propertyMap.get(key);
716         if (v == null) {
717             v = new Value();
718             v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
719             v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
720             List<Long> ll = new ArrayList<Long>();
721             v.setValue(ll);
722             propertyMap.put(key, v);
723         }
724         v.vl.add(li);
725     }
726
727     /**
728      * Add a value to a the specified string vector.
729      *
730      * @param id
731      * @param s
732      */
733     public void addString(PolicyPropertyInfo.PolicyPropertyId id, String s) {
734         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING,
735                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
736         Value v = propertyMap.get(key);
737         if (v == null) {
738             v = new Value();
739             v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING);
740             v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
741             List<String> sl = new ArrayList<String>();
742             v.setValue(sl);
743             propertyMap.put(key, v);
744         }
745         v.vl.add(s);
746     }
747
748     /**
749      * Add a value to a the specified reference vector.
750      *
751      * @param id
752      * @param pr
753      */
754     public void addReference(PolicyPropertyInfo.PolicyPropertyId id, PolicyReference pr) {
755         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE,
756                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
757         Value v = propertyMap.get(key);
758         if (v == null) {
759             v = new Value();
760             v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE);
761             v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
762             List<PolicyReference> prl = new ArrayList<PolicyReference>();
763             v.setValue(prl);
764             propertyMap.put(key, v);
765         }
766         v.vl.add(pr);
767
768     }
769
770     /**
771      * Add a value to a the specified MAC address vector.
772      *
773      * @param id
774      * @param mac
775      */
776     public void addMacAddress(PolicyPropertyInfo.PolicyPropertyId id, MacAddress mac) {
777         PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC,
778                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
779         Value v = propertyMap.get(key);
780         if (v == null) {
781             v = new Value();
782             v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC);
783             v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
784             List<MacAddress> ml = new ArrayList<MacAddress>();
785             v.setValue(ml);
786             propertyMap.put(key, v);
787         }
788         v.vl.add(mac);
789
790     }
791 }