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.ExperimenterInstructionSerializerKey;
13 import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
26 * @author michal.polkorab
28 public abstract class TypeKeyMakerFactory {
30 private TypeKeyMakerFactory() {
35 * @param version openflow wire version that shall be used
39 public static TypeKeyMaker<MatchEntry> createMatchEntriesKeyMaker(short version) {
40 return new AbstractTypeKeyMaker<MatchEntry>(version) {
42 public MatchEntrySerializerKey<?, ?> make(MatchEntry entry) {
43 MatchEntrySerializerKey<?, ?> key;
44 key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(),
45 entry.getOxmMatchField());
46 if (entry.getOxmClass().equals(ExperimenterClass.class)) {
47 ExperimenterIdCase entryValue = (ExperimenterIdCase) entry.getMatchEntryValue();
48 key.setExperimenterId(entryValue.getExperimenter().getExperimenter().getValue());
51 key.setExperimenterId(null);
58 * @param version openflow wire version that shall be used
62 public static TypeKeyMaker<Action> createActionKeyMaker(short version) {
63 return new AbstractTypeKeyMaker<Action>(version) {
65 public MessageTypeKey<?> make(Action entry) {
66 if (entry.getExperimenterId() != null) {
67 return new ActionSerializerKey<>(getVersion(),
68 (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(),
69 entry.getExperimenterId().getValue());
71 return new ActionSerializerKey<>(getVersion(),
72 (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
78 * @param version openflow wire version that shall be used
82 public static TypeKeyMaker<Instruction> createInstructionKeyMaker(short version) {
83 return new AbstractTypeKeyMaker<Instruction>(version) {
85 public MessageTypeKey<?> make(Instruction entry) {
86 if (entry.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
87 .augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase) {
88 return new ExperimenterInstructionSerializerKey(getVersion(),
89 ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction
90 .container.instruction.choice.ExperimenterIdCase) entry.getInstructionChoice())
91 .getExperimenter().getExperimenterId().getValue());
93 return new InstructionSerializerKey<>(getVersion(),
94 (Class<InstructionChoice>) entry.getInstructionChoice().getImplementedInterface(), null);