1 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf;
3 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 import java.util.List;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitionsBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
22 import com.google.common.base.Function;
23 import com.google.common.collect.Collections2;
24 import com.google.common.collect.ImmutableList;
25 import com.google.common.collect.ImmutableMap;
28 * Defines the subject features that are supported by the OF overlay renderer
30 public class SubjectFeatures {
31 private static final Map<ClassifierDefinitionId, Classifier> classifiers =
32 ImmutableMap.<ClassifierDefinitionId, Classifier>
33 of(EtherTypeClassifier.ID, Classifier.ETHER_TYPE_CL,
34 IpProtoClassifier.ID, Classifier.IP_PROTO_CL,
35 L4Classifier.ID, Classifier.L4_CL);
37 private static final List<ClassifierDefinition> classifierDefs =
38 ImmutableList.copyOf(Collections2.transform(classifiers.values(),
39 new Function<Classifier, ClassifierDefinition>() {
41 public ClassifierDefinition apply(Classifier input) {
42 return input.getClassDef();
47 private static final Map<ActionDefinitionId, Action> actions =
48 ImmutableMap.<ActionDefinitionId, Action>
49 of(AllowAction.ID, new AllowAction(),
50 ChainAction.ID, new ChainAction());
52 private static final List<ActionDefinition> actionDefs =
53 ImmutableList.copyOf(Collections2.transform(actions.values(),
54 new Function<Action, ActionDefinition>() {
56 public ActionDefinition apply(Action input) {
57 return input.getActionDef();
62 public static final SubjectFeatureDefinitions OF_OVERLAY_FEATURES =
63 new SubjectFeatureDefinitionsBuilder()
64 .setActionDefinition(actionDefs)
65 .setClassifierDefinition(classifierDefs)
69 * Get the {@link Classifier} associated with the given
70 * {@link ClassifierDefinitionId}
71 * @param id the {@link ClassifierDefinitionId} to look up
72 * @return the {@link Classifier} if one exists, or <code>null</code>
75 public static Classifier getClassifier(ClassifierDefinitionId id) {
76 return classifiers.get(id);
79 public static Map<ActionDefinitionId, Action> getActions() {
84 * Get the {@link Action} associated with the given
85 * {@link ActionDefinitionId}
86 * @param id the {@link ActionDefinitionId} to look up
87 * @return the {@link Action} if one exists, or <code>null</code>
90 public static Action getAction(ActionDefinitionId id) {
91 return actions.get(id);