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.ActionName;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitionsBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
24 import com.google.common.base.Function;
25 import com.google.common.collect.Collections2;
26 import com.google.common.collect.ImmutableList;
27 import com.google.common.collect.ImmutableMap;
30 * Defines the subject features that are supported by the OF overlay renderer
32 public class SubjectFeatures {
33 private static final Map<ClassifierDefinitionId, Classifier> classifiers =
34 ImmutableMap.<ClassifierDefinitionId, Classifier>
35 of(EtherTypeClassifier.ID, new EtherTypeClassifier(),
36 IpProtoClassifier.ID, new IpProtoClassifier(),
37 L4Classifier.ID, new L4Classifier(),
38 IpAddressClassifier.ID, new IpAddressClassifier());
40 private static final List<ClassifierDefinition> classifierDefs =
41 ImmutableList.copyOf(Collections2.transform(classifiers.values(),
42 new Function<Classifier, ClassifierDefinition>() {
44 public ClassifierDefinition apply(Classifier input) {
45 return input.getClassDef();
50 private static final Map<ActionDefinitionId, Action> actions =
51 ImmutableMap.<ActionDefinitionId, Action>
52 of(AllowAction.ID, new AllowAction());
54 public static final List<ActionDefinition> actionDefs =
55 ImmutableList.copyOf(Collections2.transform(actions.values(),
56 new Function<Action, ActionDefinition>() {
58 public ActionDefinition apply(Action input) {
59 return input.getActionDef();
65 public static final SubjectFeatureDefinitions OF_OVERLAY_FEATURES =
66 new SubjectFeatureDefinitionsBuilder()
67 .setActionDefinition(actionDefs)
68 .setClassifierDefinition(classifierDefs)
72 * Get the {@link Classifier} associated with the given
73 * {@link ClassifierDefinitionId}
74 * @param id the {@link ClassifierDefinitionId} to look up
75 * @return the {@link Classifier} if one exists, or <code>null</code>
78 public static Classifier getClassifier(ClassifierDefinitionId id) {
79 return classifiers.get(id);
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);