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());
39 private static final List<ClassifierDefinition> classifierDefs =
40 ImmutableList.copyOf(Collections2.transform(classifiers.values(),
41 new Function<Classifier, ClassifierDefinition>() {
43 public ClassifierDefinition apply(Classifier input) {
44 return input.getClassDef();
49 private static final Map<ActionDefinitionId, Action> actions =
50 ImmutableMap.<ActionDefinitionId, Action>
51 of(AllowAction.ID, new AllowAction());
53 public static final List<ActionDefinition> actionDefs =
54 ImmutableList.copyOf(Collections2.transform(actions.values(),
55 new Function<Action, ActionDefinition>() {
57 public ActionDefinition apply(Action input) {
58 return input.getActionDef();
64 public static final SubjectFeatureDefinitions OF_OVERLAY_FEATURES =
65 new SubjectFeatureDefinitionsBuilder()
66 .setActionDefinition(actionDefs)
67 .setClassifierDefinition(classifierDefs)
71 * Get the {@link Classifier} associated with the given
72 * {@link ClassifierDefinitionId}
73 * @param id the {@link ClassifierDefinitionId} to look up
74 * @return the {@link Classifier} if one exists, or <code>null</code>
77 public static Classifier getClassifier(ClassifierDefinitionId id) {
78 return classifiers.get(id);
82 * Get the {@link Action} associated with the given
83 * {@link ActionDefinitionId}
84 * @param id the {@link ActionDefinitionId} to look up
85 * @return the {@link Action} if one exists, or <code>null</code>
88 public static Action getAction(ActionDefinitionId id) {
89 return actions.get(id);