Initial code drop
[bgpcep.git] / bgp / util / src / main / java / org / opendaylight / protocol / bgp / util / AbstractBGPPrefix.java
1 /*
2  * Copyright (c) 2013 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.util;
9
10 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
11 import org.opendaylight.protocol.bgp.parser.BGPPrefix;
12 import org.opendaylight.protocol.bgp.parser.BGPPrefixState;
13
14 import org.opendaylight.protocol.concepts.NetworkAddress;
15 import org.opendaylight.protocol.bgp.linkstate.PrefixIdentifier;
16 import org.opendaylight.protocol.bgp.linkstate.NetworkPrefixState;
17 import com.google.common.base.Preconditions;
18
19 /**
20  * Super class for BGPIpvXPrefixImpl.
21  * 
22  * @param <T> extends NetworkAddress<T>
23  */
24 public abstract class AbstractBGPPrefix<T extends NetworkAddress<T>> extends AbstractBGPObject implements BGPPrefix<T> {
25         private static final long serialVersionUID = 1L;
26         private final PrefixIdentifier<T> descriptor;
27
28         protected AbstractBGPPrefix(final BaseBGPObjectState base, final PrefixIdentifier<T> descriptor, final NetworkPrefixState prefixState) {
29                 super(new BGPPrefixState(base, prefixState));
30                 Preconditions.checkNotNull(descriptor);
31                 this.descriptor = descriptor;
32         }
33
34         @Override
35         public final PrefixIdentifier<T> getPrefixIdentifier() {
36                 return this.descriptor;
37         }
38
39         @Override
40         final public BGPPrefixState currentState() {
41                 return (BGPPrefixState) super.currentState();
42         }
43 }