2 * Copyright (c) 2014, 2015 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.openflowplugin.api.openflow.md.util;
11 import com.google.common.collect.ImmutableMap;
12 import com.google.common.collect.Maps;
13 import java.util.Arrays;
14 import org.opendaylight.yangtools.yang.common.Uint8;
17 * List of Openflow versions supported by the plugin.
18 * Note: If you add a version here,
19 * make sure to update org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil as well.
20 * @deprecated enum in api is not something what we would like to see in case it is evolving.
22 public enum OpenflowVersion {
26 UNSUPPORTED((short)0x00);
28 private static final ImmutableMap<Uint8, OpenflowVersion> VERSIONS = Maps.uniqueIndex(Arrays.asList(values()),
29 ver -> Uint8.valueOf(ver.version));
31 private short version;
33 OpenflowVersion(final short version) {
34 this.version = version;
37 public static OpenflowVersion get(final Uint8 version) {
38 final OpenflowVersion ver = VERSIONS.get(version);
39 return ver != null ? ver : UNSUPPORTED;
42 public static OpenflowVersion get(final Short version) {
43 for (final OpenflowVersion ofv : OpenflowVersion.values()) {
44 if (ofv.version == version) {
55 public short getVersion() {