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;
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) {
}
}
));
-
- 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);
+ }
}