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.ofoverlay.sf;
11 import java.util.List;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitionsBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
21 import com.google.common.base.Function;
22 import com.google.common.collect.Collections2;
23 import com.google.common.collect.ImmutableList;
24 import com.google.common.collect.ImmutableMap;
27 * Defines the subject features that are supported by the OF overlay renderer
29 public class SubjectFeatures {
30 private static final Map<ClassifierDefinitionId, Classifier> classifiers =
31 ImmutableMap.<ClassifierDefinitionId, Classifier>
32 of(EtherTypeClassifier.ID, Classifier.ETHER_TYPE_CL,
33 IpProtoClassifier.ID, Classifier.IP_PROTO_CL,
34 L4Classifier.ID, Classifier.L4_CL);
36 private static final List<ClassifierDefinition> classifierDefs =
37 ImmutableList.copyOf(Collections2.transform(classifiers.values(),
38 new Function<Classifier, ClassifierDefinition>() {
40 public ClassifierDefinition apply(Classifier input) {
41 return input.getClassDef();
46 private static final Map<ActionDefinitionId, Action> actions =
47 ImmutableMap.<ActionDefinitionId, Action>
48 of(AllowAction.ID, new AllowAction());
50 private static final List<ActionDefinition> actionDefs =
51 ImmutableList.copyOf(Collections2.transform(actions.values(),
52 new Function<Action, ActionDefinition>() {
54 public ActionDefinition apply(Action input) {
55 return input.getActionDef();
60 public static final SubjectFeatureDefinitions OF_OVERLAY_FEATURES =
61 new SubjectFeatureDefinitionsBuilder()
62 .setActionDefinition(actionDefs)
63 .setClassifierDefinition(classifierDefs)
67 * Get the {@link Classifier} associated with the given
68 * {@link ClassifierDefinitionId}
69 * @param id the {@link ClassifierDefinitionId} to look up
70 * @return the {@link Classifier} if one exists, or <code>null</code>
73 public static Classifier getClassifier(ClassifierDefinitionId id) {
74 return classifiers.get(id);
78 * Get the {@link Action} associated with the given
79 * {@link ActionDefinitionId}
80 * @param id the {@link ActionDefinitionId} to look up
81 * @return the {@link Action} if one exists, or <code>null</code>
84 public static Action getAction(ActionDefinitionId id) {
85 return actions.get(id);