2 * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.openflowjava.protocol.impl.util;
11 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
12 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
13 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
27 * @author michal.polkorab
29 public abstract class TypeKeyMakerFactory {
31 private TypeKeyMakerFactory() {
36 * @param version openflow wire version that shall be used
40 public static TypeKeyMaker<MatchEntry> createMatchEntriesKeyMaker(short version) {
41 return new AbstractTypeKeyMaker<MatchEntry>(version) {
43 public MatchEntrySerializerKey<?, ?> make(MatchEntry entry) {
44 MatchEntrySerializerKey<?, ?> key;
45 key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(),
46 entry.getOxmMatchField());
47 if (entry.getOxmClass().equals(ExperimenterClass.class)) {
48 ExperimenterIdCase entryValue = (ExperimenterIdCase) entry.getMatchEntryValue();
49 key.setExperimenterId(entryValue.getExperimenter().getExperimenter().getValue());
52 key.setExperimenterId(null);
59 * @param version openflow wire version that shall be used
63 public static TypeKeyMaker<Action> createActionKeyMaker(short version) {
64 return new AbstractTypeKeyMaker<Action>(version) {
66 public MessageTypeKey<?> make(Action entry) {
67 if (entry.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
68 .augments.rev150225.action.container.action.choice.ExperimenterIdCase) {
69 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action
70 .container.action.choice.ExperimenterIdCase expIdCase = (org.opendaylight.yang.gen.v1.urn
71 .opendaylight.openflow.augments.rev150225.action.container.action.choice
72 .ExperimenterIdCase) entry.getActionChoice();
73 return new ExperimenterActionSerializerKey(getVersion(),
74 expIdCase.getExperimenter().getExperimenter().getValue(),
75 expIdCase.getExperimenter().getSubType());
77 return new ActionSerializerKey<>(getVersion(),
78 (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
84 * @param version openflow wire version that shall be used
88 public static TypeKeyMaker<Instruction> createInstructionKeyMaker(short version) {
89 return new AbstractTypeKeyMaker<Instruction>(version) {
91 public MessageTypeKey<?> make(Instruction entry) {
92 if (entry.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
93 .augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase) {
94 return new ExperimenterInstructionSerializerKey(getVersion(),
95 ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction
96 .container.instruction.choice.ExperimenterIdCase) entry.getInstructionChoice())
97 .getExperimenter().getExperimenterId().getValue());
99 return new InstructionSerializerKey<>(getVersion(),
100 (Class<InstructionChoice>) entry.getInstructionChoice().getImplementedInterface(), null);