Initial code drop
[bgpcep.git] / concepts / src / main / java / org / opendaylight / protocol / concepts / Prefix.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.concepts;
9
10 import org.opendaylight.protocol.concepts.Identifier;
11
12 /**
13  * A network prefix object. Prefix is a networking concept grouping together
14  * a set of addresses into a 'subnet', such that their attributes can be easily
15  * expressed. A prefix is formed by a base NetworkAddress and number of leading
16  * bits which are considered significant. An address is considered to be a part
17  * of a prefix if it differes only in insignificant (right-most) bits.
18  *
19  * @param <T> template reference to a Network Address class
20  */
21 public interface Prefix<T extends NetworkAddress<?>> extends Identifier {
22         /**
23          * Get the base address of the prefix.
24          *
25          * @return Base network address
26          */
27         public T getAddress();
28
29         /**
30          * The the length of significant part of the base address.
31          *
32          * @return Prefix length
33          */
34         public int getLength();
35
36         /**
37          * Check if a Prefix contains a particular network address.
38          *
39          * @param address Network address to check for membership
40          * @return true if address belongs to this subnet, false otherwise
41          */
42         public boolean contains(NetworkAddress<?> address);
43
44         /**
45          * Returns the address family class.
46          * 
47          * @return address family class
48          */
49         public AddressFamily<T> getAddressFamily();
50 }
51