de66318c4631d182f2c620b02630dc4a87c315f8
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / spi / AbstractBestPath.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.mode.spi;
10
11 import static java.util.Objects.requireNonNull;
12
13 import com.google.common.annotations.VisibleForTesting;
14 import com.google.common.base.MoreObjects;
15 import org.opendaylight.protocol.bgp.mode.api.BestPath;
16 import org.opendaylight.protocol.bgp.mode.api.BestPathState;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
18
19 public abstract class AbstractBestPath implements BestPath {
20     protected final BestPathState state;
21
22     protected AbstractBestPath(final BestPathState state) {
23         this.state = requireNonNull(state);
24     }
25
26     protected abstract MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper);
27
28     @VisibleForTesting
29     public final BestPathState getState() {
30         return this.state;
31     }
32
33     @Override
34     public final Attributes getAttributes() {
35         return this.state.getAttributes();
36     }
37
38     @Override
39     public final String toString() {
40         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
41     }
42 }