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.InstructionSerializerKey;
13 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
25 * @author michal.polkorab
27 public abstract class TypeKeyMakerFactory {
29 private TypeKeyMakerFactory() {
34 * @param version openflow wire version that shall be used
38 public static TypeKeyMaker<MatchEntry> createMatchEntriesKeyMaker(short version) {
39 return new AbstractTypeKeyMaker<MatchEntry>(version) {
41 public MatchEntrySerializerKey<?, ?> make(MatchEntry entry) {
42 MatchEntrySerializerKey<?, ?> key;
43 key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(),
44 entry.getOxmMatchField());
45 if (entry.getOxmClass().equals(ExperimenterClass.class)) {
46 ExperimenterIdCase entryValue = (ExperimenterIdCase) entry.getMatchEntryValue();
47 key.setExperimenterId(entryValue.getExperimenter().getExperimenter().getValue());
50 key.setExperimenterId(null);
57 * @param version openflow wire version that shall be used
61 public static TypeKeyMaker<Action> createActionKeyMaker(short version) {
62 return new AbstractTypeKeyMaker<Action>(version) {
64 public MessageTypeKey<?> make(Action entry) {
65 if (entry.getExperimenterId() != null) {
66 return new ActionSerializerKey<>(getVersion(),
67 (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(),
68 entry.getExperimenterId().getValue());
70 return new ActionSerializerKey<>(getVersion(),
71 (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
77 * @param version openflow wire version that shall be used
81 public static TypeKeyMaker<Instruction> createInstructionKeyMaker(short version) {
82 return new AbstractTypeKeyMaker<Instruction>(version) {
84 public MessageTypeKey<?> make(Instruction entry) {
85 if (entry.getExperimenterId() != null) {
86 return new InstructionSerializerKey<>(getVersion(),
87 (Class<InstructionChoice>) entry.getInstructionChoice().getImplementedInterface(),
88 entry.getExperimenterId().getValue());
90 return new InstructionSerializerKey<>(getVersion(),
91 (Class<InstructionChoice>) entry.getInstructionChoice().getImplementedInterface(), null);