Merge "Device*Registry quickfix - add failed"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / util / TranslatorLibraryUtil.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.util;
10
11 import org.opendaylight.openflowplugin.api.OFConstants;
12 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
13 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
14 import org.opendaylight.openflowplugin.impl.translator.AggregatedFlowStatisticsTranslator;
15 import org.opendaylight.openflowplugin.impl.translator.FlowRemovedTranslator;
16 import org.opendaylight.openflowplugin.impl.translator.FlowRemovedV10Translator;
17 import org.opendaylight.openflowplugin.impl.translator.PacketReceivedTranslator;
18 import org.opendaylight.openflowplugin.impl.translator.PortUpdateTranslator;
19 import org.opendaylight.openflowplugin.impl.translator.TranslatorKeyFactory;
20 import org.opendaylight.openflowplugin.impl.translator.TranslatorLibraryBuilder;
21 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
26
27 /**
28  * Created by Martin Bobak <mbobak@cisco.com> on 3.4.2015.
29  */
30 public final class TranslatorLibraryUtil {
31
32
33     private TranslatorLibraryUtil() {
34         throw new IllegalStateException("This class should not be instantiated");
35     }
36
37     private static final TranslatorKeyFactory of13TranslatorKeyFactory = new TranslatorKeyFactory(OFConstants.OFP_VERSION_1_3);
38     private static final TranslatorKeyFactory of10TranslatorKeyFactory = new TranslatorKeyFactory(OFConstants.OFP_VERSION_1_0);
39
40     public static void injectBasicTranslatorLibrary(final TranslatorLibrarian librarian, final ConvertorExecutor convertorExecutor) {
41         final TranslatorLibrary basicTranslatorLibrary = new TranslatorLibraryBuilder().
42                 addTranslator(of13TranslatorKeyFactory.createTranslatorKey(PacketIn.class), new PacketReceivedTranslator(convertorExecutor)).
43                 addTranslator(of13TranslatorKeyFactory.createTranslatorKey(PortGrouping.class), new PortUpdateTranslator()).
44                 addTranslator(of13TranslatorKeyFactory.createTranslatorKey(MultipartReplyAggregateCase.class), new AggregatedFlowStatisticsTranslator()).
45                 addTranslator(of13TranslatorKeyFactory.createTranslatorKey(FlowRemoved.class), new FlowRemovedTranslator(convertorExecutor)).
46                 addTranslator(of10TranslatorKeyFactory.createTranslatorKey(PacketIn.class), new PacketReceivedTranslator(convertorExecutor)).
47                 addTranslator(of10TranslatorKeyFactory.createTranslatorKey(PortGrouping.class), new PortUpdateTranslator()).
48                 addTranslator(of10TranslatorKeyFactory.createTranslatorKey(MultipartReplyAggregateCase.class), new AggregatedFlowStatisticsTranslator()).
49                 addTranslator(of10TranslatorKeyFactory.createTranslatorKey(FlowRemoved.class), new FlowRemovedV10Translator(convertorExecutor)).
50
51                 build();
52
53         librarian.setTranslatorLibrary(basicTranslatorLibrary);
54     }
55 }