23d3d8b4cc8eeb7b431e783653b75116ed838a02
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / BesthPathStateUtil.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.mode;
9
10 import java.util.List;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments;
12
13 public final class BesthPathStateUtil {
14     private BesthPathStateUtil() {
15         throw new UnsupportedOperationException();
16     }
17
18     public static long getPeerAs(final List<Segments> segments) {
19         for (final Segments seg : segments) {
20             if (seg.getAsSequence() != null && !seg.getAsSequence().isEmpty()) {
21                 return segments.get(0).getAsSequence().get(0).getValue();
22             }
23         }
24         return 0;
25     }
26 }