2 * Copyright (c) 2018 AT&T Intellectual Property. 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.protocol.bgp.mode;
10 import java.util.List;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments;
14 public final class BesthPathStateUtil {
15 private BesthPathStateUtil() {
16 throw new UnsupportedOperationException();
19 public static AsNumber getPeerAs(final List<Segments> segments) {
20 if (segments.isEmpty()) {
21 return new AsNumber(0L);
23 for (final Segments seg : segments) {
24 if (seg.getAsSequence() != null && !seg.getAsSequence().isEmpty()) {
25 return segments.get(0).getAsSequence().get(0);
28 return new AsNumber(0L);