Remove useless UnsupportedOperationExceptions
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / RouterIds.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 package org.opendaylight.protocol.bgp.rib.spi;
9
10 import org.eclipse.jdt.annotation.NonNullByDefault;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
14
15 @NonNullByDefault
16 public final class RouterIds {
17     private RouterIds() {
18         // Hidden on purpose
19     }
20
21     public static PeerId createPeerId(final IpAddress address) {
22         final Ipv4Address ipv4 = address.getIpv4Address();
23         return ipv4 != null ? createPeerId(ipv4)
24                 : new PeerId(RouterId.PEER_ID_PREFIX + address.getIpv6Address().getValue());
25     }
26
27     public static PeerId createPeerId(final Ipv4Address address) {
28         return new PeerId(RouterId.PEER_ID_PREFIX + address.getValue());
29     }
30 }