Propagate depreferenced status through AbstractAdvertizedRoute
[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 package org.opendaylight.protocol.bgp.mode.spi;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.VisibleForTesting;
13 import com.google.common.base.MoreObjects;
14 import org.opendaylight.protocol.bgp.mode.api.BestPath;
15 import org.opendaylight.protocol.bgp.mode.api.BestPathState;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
17
18 public abstract class AbstractBestPath implements BestPath {
19     protected final BestPathState state;
20
21     protected AbstractBestPath(final BestPathState state) {
22         this.state = requireNonNull(state);
23     }
24
25     protected abstract MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper);
26
27     @VisibleForTesting
28     public final BestPathState getState() {
29         return this.state;
30     }
31
32     @Override
33     public final Attributes getAttributes() {
34         return this.state.getAttributes();
35     }
36
37     @Override
38     public final boolean isDepreferenced() {
39         return this.state.isDepreferenced();
40     }
41
42     @Override
43     public final String toString() {
44         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
45     }
46 }