Exported package for classifier-definitions and action-definitions
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / SubjectFeatures.java
index 7d8377d7f95dabfbdbe95a2a3bba6de24948e1eb..64822f1ca78a458e7ef4c100aee7e3e4c0f6f92d 100644 (file)
@@ -12,13 +12,10 @@ import java.util.List;
 import java.util.Map;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
 
 import com.google.common.base.Function;
@@ -32,12 +29,12 @@ import com.google.common.collect.ImmutableMap;
 public class SubjectFeatures {
     private static final Map<ClassifierDefinitionId, Classifier> classifiers =
             ImmutableMap.<ClassifierDefinitionId, Classifier>
-                of(EtherTypeClassifier.ID, new EtherTypeClassifier(),
-                   IpProtoClassifier.ID, new IpProtoClassifier(),
-                   L4Classifier.ID, new L4Classifier());
+                of(EtherTypeClassifier.ID, Classifier.ETHER_TYPE_CL,
+                   IpProtoClassifier.ID, Classifier.IP_PROTO_CL,
+                   L4Classifier.ID, Classifier.L4_CL);
 
     private static final List<ClassifierDefinition> classifierDefs =
-            ImmutableList.copyOf(Collections2.transform(classifiers.values(), 
+            ImmutableList.copyOf(Collections2.transform(classifiers.values(),
                 new Function<Classifier, ClassifierDefinition>() {
                     @Override
                     public ClassifierDefinition apply(Classifier input) {
@@ -45,29 +42,46 @@ public class SubjectFeatures {
                     }
                 }
             ));
-    
-    public static final ActionDefinition ALLOW = 
-            new ActionDefinitionBuilder()
-                .setId(new ActionDefinitionId("f942e8fd-e957-42b7-bd18-f73d11266d17"))
-                .setName(new ActionName("allow"))
-                .setDescription(new Description("Allow the specified traffic to pass"))
-                .build();
+
+    private static final Map<ActionDefinitionId, Action> actions =
+            ImmutableMap.<ActionDefinitionId, Action>
+                of(AllowAction.ID, new AllowAction());
+
+    private static final List<ActionDefinition> actionDefs =
+            ImmutableList.copyOf(Collections2.transform(actions.values(),
+                new Function<Action, ActionDefinition>() {
+                    @Override
+                    public ActionDefinition apply(Action input) {
+                        return input.getActionDef();
+                    }
+                }
+             ));
 
     public static final SubjectFeatureDefinitions OF_OVERLAY_FEATURES =
             new SubjectFeatureDefinitionsBuilder()
-                .setActionDefinition(ImmutableList.of(ALLOW))
+                .setActionDefinition(actionDefs)
                 .setClassifierDefinition(classifierDefs)
                 .build();
 
     /**
-     * Get the {@link Classifier} associated with the given 
+     * Get the {@link Classifier} associated with the given
      * {@link ClassifierDefinitionId}
      * @param id the {@link ClassifierDefinitionId} to look up
-     * @return the {@link Classifier} if one exists, or <code>null</code> 
+     * @return the {@link Classifier} if one exists, or <code>null</code>
      * otherwise
      */
     public static Classifier getClassifier(ClassifierDefinitionId id) {
         return classifiers.get(id);
     }
-                                           
+
+    /**
+     * Get the {@link Action} associated with the given
+     * {@link ActionDefinitionId}
+     * @param id the {@link ActionDefinitionId} to look up
+     * @return the {@link Action} if one exists, or <code>null</code>
+     * otherwise
+     */
+    public static Action getAction(ActionDefinitionId id) {
+        return actions.get(id);
+    }
 }