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;
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
16 import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId;
21 * Class that provides Managed Object metadata. The
22 * {@link PolicyClassInfo} object contains metadata about
23 * the Managed Object, while the {@link PropertyInfo} list
24 * contained by this object provides the metadata about the
25 * Managed Object properties.
27 * This data must be kept consistent with the agents.
32 public interface PolicyClassInfo {
34 static public enum PolicyClassType {
36 REMOTE_ENDPOINT("remote_endpoint"),
37 LOCAL_ENDPOINT("local_endpoint"),
38 OBSERVABLE("observable"),
39 LOCAL_ONLY("local_only"),
41 RELATIONSHIP("relationship"),
42 REVERSE_RELATIONSHIP("reverse_relationship");
44 private final String type;
46 PolicyClassType(String type) {
51 public String toString() {
57 * Get the ID for the class
61 public int getClassId() ;
64 * Get the type for the class
68 public PolicyClassType getPolicyType();
71 * Get the name for the class
75 public String getClassName();
78 * Get a {@link PolicyPropertyInfo} object by name
84 public PolicyPropertyInfo getProperty(String name);
87 * Return the entire list of {@link PolicyPropertyInfo}
88 * objects for this class.
92 public List<PolicyPropertyInfo> getProperties();
95 * Get a list of {@link PolicyPropertyId} objects,
96 * which are the keys to the {@link PolicyPropertyInfo}
97 * objects for this class.
101 public List<PolicyPropertyId> getKeys();
104 * A builder class for create immutable instances of
105 * {@link PolicyClassInfo} objects.
110 public static class PolicyClassInfoBuilder {
112 private PolicyClassType policyType;
113 private String className;
114 private Map<String, PolicyPropertyInfo> properties;
115 private List<PolicyPropertyId> keys;
117 public PolicyClassInfoBuilder() {
118 this.properties = new HashMap<String, PolicyPropertyInfo>();
119 this.keys = new ArrayList<PolicyPropertyId>();
122 public int getClassId() {
126 public PolicyClassInfoBuilder setClassId(int classId) {
127 this.classId = classId;
131 public PolicyClassType getPolicyType() {
135 public PolicyClassInfoBuilder setPolicyType(PolicyClassType policyType) {
136 this.policyType = policyType;
140 public String getClassName() {
144 public PolicyClassInfoBuilder setClassName(String className) {
145 this.className = className;
149 public PolicyClassInfoBuilder setProperty(List<PolicyPropertyInfo> ppil) {
150 for (PolicyPropertyInfo ppi: ppil) {
151 this.properties.put(ppi.getPropName(),ppi);
156 public PolicyClassInfoBuilder setKey(List<PolicyPropertyId> pidl) {
157 this.keys.addAll(pidl);
161 public PolicyClassInfo build() {
162 return new PolicyClassInfoImpl(this);
165 private static final class PolicyClassInfoImpl implements PolicyClassInfo {
167 private final int classId;
168 private final PolicyClassType policyType;
169 private final String className;
170 private final Map<String, PolicyPropertyInfo> properties;
171 private List<PolicyPropertyId> keys;
173 private PolicyClassInfoImpl(PolicyClassInfoBuilder builder) {
174 this.classId = builder.classId;
175 this.policyType = builder.policyType;
176 this.className = builder.className;
177 this.properties = builder.properties;
178 this.keys = builder.keys;
181 public int getClassId() {
186 public PolicyClassType getPolicyType() {
191 public String getClassName() {
196 public PolicyPropertyInfo getProperty(String name) {
197 return properties.get(name);
201 public List<PolicyPropertyInfo> getProperties() {
202 return new ArrayList<PolicyPropertyInfo>(properties.values());
206 public List<PolicyPropertyId> getKeys() {