2 * Copyright (c) 2017 6WIND, Inc. 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
8 package org.opendaylight.netvirt.neutronvpn.api.enums;
10 /**this enum is used to make a choice between IPv4 or IPv6 or both.
12 public enum IpVersionChoice {
17 public final int choice;
19 IpVersionChoice(int value) {
23 public boolean isIpVersionChosen(IpVersionChoice arg) {
24 if (this.choice == IpVersionChoice.IPV4AND6.choice || this.choice == arg.choice) {
30 /**used to get an association of ipv4 and/or ipv6 choice if it is possible.
31 * @param ipVers the IP version to combine with this
32 * @return the new IpVersionChoice
34 public IpVersionChoice addVersion(IpVersionChoice ipVers) {
38 if (this.choice == UNDEFINED.choice) {
41 if (this.choice == IPV4AND6.choice || ipVers.choice == IPV4AND6.choice) {
44 int newChoice = this.choice + ipVers.choice;
46 case 4: return IpVersionChoice.IPV4;
47 case 8: return IpVersionChoice.IPV4;
49 case 6: return IpVersionChoice.IPV6;
50 case 12: return IpVersionChoice.IPV6;
52 case 10: return IpVersionChoice.IPV4AND6;
54 default: return IpVersionChoice.UNDEFINED;