public final class VniRange extends Object
valueOf(java.lang.String)
factory method.
A string specification is used to define the VNI range, using the form:
{first}-{last}where first and last are values accepted by the
Vni.valueOf(String)
method.
For example, the specification "15-30"
declares that the range
of VNIs starts with 15 and ends with 30.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractRange.RangeIterator<V extends Comparable<V>>
A partial implementation of a range iterator.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
E_BAD_SPEC
Exception message prefix for bad specification string.
|
protected T |
first |
protected static int |
FIRST
Index for first item returned by
splitSpec(String) . |
protected static String |
HYPHEN
The hyphen character, "-".
|
protected T |
last |
protected static int |
LAST
Index for last item returned by
splitSpec(String) . |
protected static Random |
RANDOM
Random number generator.
|
protected int |
size |
protected String |
spec |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(com.hp.util.ip.AbstractRange<T> other)
Returns
true if this range is a superset of the
other range; false otherwise. |
boolean |
contains(T item)
Returns
true if this range contains the specified item;
false otherwise. |
boolean |
equals(Object o) |
T |
first()
Returns the first item in the range.
|
int |
hashCode() |
boolean |
intersects(com.hp.util.ip.AbstractRange<T> other) |
Iterator<Vni> |
iterator()
Returns an iterator for the range.
|
T |
last()
Returns the last item in the range.
|
protected void |
parseSpec(String spec)
|
Vni |
random()
Returns a randomly generated item that falls within this range.
|
long |
size()
Returns the size of the range.
|
protected String[] |
splitSpec(String spec)
Convenience method to split the given string using hyphen as the
delimiter.
|
String |
toDebugString()
Returns a multi-line string representing the internal state of this
range.
|
String |
toString() |
static VniRange |
valueOf(String spec)
Returns a Virtual Network Identifier (VNI) range instance, representing
a range of VNI values.
|
static VniRange |
valueOf(Vni first,
Vni last)
Returns a Virtual Network Identifier (VNI) range instance, representing a
range of VNI values from
first to last , inclusively. |
protected static final String E_BAD_SPEC
protected static final int FIRST
splitSpec(String)
.protected static final int LAST
splitSpec(String)
.protected static final String HYPHEN
protected static final Random RANDOM
protected final String spec
protected T extends Comparable<T> first
protected T extends Comparable<T> last
protected int size
protected void parseSpec(String spec)
first
, last
, and size
appropriately.
This method is invoked from the constructor.spec
- the range specificationpublic Vni random()
public Iterator<Vni> iterator()
first()
and ending with the
last()
, emitting a total count of size()
items.public static VniRange valueOf(String spec)
"{first}-{last}"
spec
- the range specificationpublic static VniRange valueOf(Vni first, Vni last)
first
to last
, inclusively.first
- the first Vni in the rangelast
- the last Vni in the rangeNullPointerException
- if either parameter is nullpublic String toDebugString()
protected String[] splitSpec(String spec)
spec
- the range specificationpublic T first()
public T last()
public long size()
public boolean contains(T item)
true
if this range contains the specified item;
false otherwise.item
- the item to testpublic boolean contains(com.hp.util.ip.AbstractRange<T> other)
true
if this range is a superset of the
other range; false otherwise.
Put another way, the set of all items T_other
produced by
other.iterator()
is a subset of the set of all items
T_this
produced by this.iterator()
.other
- the other range to compare withIllegalArgumentException
- if other range is not the same type
as this oneNullPointerException
- if other is nullpublic boolean intersects(com.hp.util.ip.AbstractRange<T> other)
Copyright © 2015. All Rights Reserved.