public final class MiscUtils extends Object
MiscUtils
class is a collection of miscellaneous utility class
methods.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_VLAN_ID
Default VLAN ID.
|
static String |
LOG_SEPARATOR
A string to be used as a field separator in a log message.
|
static int |
ORDER_MIN
The minimum value of the order value for the first element in the
ordered list.
|
static org.slf4j.Logger |
VERBOSE_LOG
A logger for extra verbose logging.
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
cast(Class<T> type,
Object obj)
Cast an object type to the specified type.
|
static VnodeName |
checkName(String desc,
String name)
Check the specified resource name.
|
static String |
checkName(String desc,
VnodeName vname)
Check the specified resource name.
|
static void |
checkPresent(String desc,
VnodeName vname)
Ensure the given vnode-name is not null.
|
static double |
doubleValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 c)
Return the value in the given 32-bit counter.
|
static double |
doubleValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 c)
Return the value in the given 64-bit counter.
|
static <T extends org.opendaylight.yangtools.yang.binding.Identifiable<?>> |
equalsAsMap(Collection<T> c1,
Collection<T> c2)
Determine whether the given two keyed data object lists are identical
or not.
|
static <T> boolean |
equalsAsSet(Collection<T> c1,
Collection<T> c2)
Determine whether the given two collections are identical or not.
|
static boolean |
equalsUri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri u1,
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri u2)
Determine whether the given two URIs are identical or not.
|
static String |
getValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri uri)
Return a string configured in the given URI.
|
static String |
getValue(VnodeName vname)
Return a string configured in the given vnode-name.
|
static org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId |
getVlanId(VtnVlanIdField field)
Return a VLAN ID configured in the given
VtnVlanIdField
instance. |
static boolean |
isBadRequest(Throwable t)
Determine whether the given throwable is caused by a bad user request
or not.
|
static boolean |
isEmpty(Collection<?> c)
Determine whether the given collection is empty or not.
|
static String |
join(String separator,
Collection<?> objs)
Stringify all the elements in the given collection, and join them with
inserting the given separator.
|
static String |
join(String separator,
Object... objs)
Stringify the given objects, and join them with inserting the given
separator.
|
static String |
joinColon(Object... objs)
Stringify the given objects, and join them with inserting ": " as a
separator.
|
static long |
longValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 c)
Return the value in the given 32-bit counter.
|
static long |
longValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 c)
Return the value in the given 64-bit counter.
|
static <T> List<T> |
sortedCopy(List<T> list,
Comparator<? super T> comp)
Return the copy of the given list sorted by the given comparator.
|
static EtherAddress |
toEtherAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress mac)
Convert the given
MacAddress instance into an
EtherAddress instance. |
static String |
toLowerCase(String str)
Convert all of the characters in the given string to lower case.
|
static String |
toLowerCase(VtnUpdateType type)
Convert all of the characters in the given
VtnUpdateType name
to lower case. |
static <T> List<T> |
toValueList(Map<?,T> map)
Convert values in the given map into a list.
|
static VnodeState |
toVnodeState(boolean b)
Convert a boolean value into a
VnodeState instance. |
static IllegalStateException |
unexpected()
Return an
IllegalStateException which indicates unexpected
method is called. |
static <T> Set<T> |
unmodifiableKeySet(Map<T,?> src)
Return an unmodifiable set equivalent to the key set in the given map.
|
static <T> List<T> |
unmodifiableList(List<T> src)
Return an unmodifiable list equivalent to the given list.
|
static <T> Set<T> |
unmodifiableSet(Set<T> src)
Return an unmodifiable set equivalent to the given set.
|
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress |
verify(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress mac)
Verify the given MAC address.
|
public static final org.slf4j.Logger VERBOSE_LOG
public static final String LOG_SEPARATOR
public static final int ORDER_MIN
public static final int DEFAULT_VLAN_ID
public static EtherAddress toEtherAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress mac) throws RpcException
MacAddress
instance into an
EtherAddress
instance.mac
- A MacAddress
instance.EtherAddress
instance.
null
if mac
is null
.RpcException
- The given MAC address is invalid.public static VnodeName checkName(String desc, String name) throws RpcException
desc
- Brief description of the resource.name
- The name of the resource.VnodeName
instance that contains the given name.RpcException
- The specified name is invalid.public static String checkName(String desc, VnodeName vname) throws RpcException
desc
- Brief description of the resource.vname
- A VnodeName
instance.vname
.RpcException
- The specified name is invalid.public static void checkPresent(String desc, VnodeName vname) throws RpcException
desc
- Brief description of the resource.vname
- A VnodeName
instance.RpcException
- vname
is null
.public static String joinColon(Object... objs)
objs
- Objects to be joined.public static String join(String separator, Object... objs)
separator
- A separater to be inserted.objs
- Objects to be joined.public static String join(String separator, Collection<?> objs)
separator
- A separater to be inserted.objs
- A collection of objects to be joined.public static <T> T cast(Class<T> type, Object obj)
T
- The target type.type
- A class that indicates the target type.obj
- An object to be casted.null
.public static String toLowerCase(String str)
str
- A string to be converted.public static String toLowerCase(VtnUpdateType type)
VtnUpdateType
name
to lower case.type
- A VtnUpdateType
instance.public static IllegalStateException unexpected()
IllegalStateException
which indicates unexpected
method is called.IllegalStateException
instance.public static long longValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 c)
c
- The 32-bit counter.c
is invalid.public static long longValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 c)
c
- The 64-bit counter.c
is invalid.public static double doubleValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 c)
c
- The 32-bit counter.c
is invalid.public static double doubleValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64 c)
c
- The 64-bit counter.c
is invalid.public static <T> List<T> sortedCopy(List<T> list, Comparator<? super T> comp)
T
- The type of elements in the list.list
- A list to be copied.comp
- A comparator for the given list.public static boolean equalsUri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri u1, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri u2)
Note that this method compares only strings configured in the given URIs. The type of classes are never compared.
u1
- The first instance to be compared.u2
- The second instance to be compared.true
only if vh1
and vh2
are identical.public static <T> boolean equalsAsSet(Collection<T> c1, Collection<T> c2)
This method compares the given collections as sets. Duplicate elements in the given collections are ignored.
T
- The type of elements in the given collections.c1
- The first collections to be compared.
null
is treated as an empty collection.c2
- The second collections to be compared.
null
is treated as an empty collection.true
only if c1
and c2
are identical.public static <T extends org.opendaylight.yangtools.yang.binding.Identifiable<?>> boolean equalsAsMap(Collection<T> c1, Collection<T> c2)
This method compares the given collections as map keyed by the key
defined by Identifiable
. Duplicate elements in the given
collections are ignored.
T
- The type of elements in the given collections.c1
- The first collections to be compared.
null
is treated as an empty collection.
Note that the collection must not contain null
.c2
- The second collections to be compared.
null
is treated as an empty collection.
Note that the collection must not contain null
.true
only if c1
and c2
are identical.public static String getValue(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri uri)
uri
- An Uri
instance.null
is returned if uri
is
null
.public static String getValue(VnodeName vname)
vname
- An VnodeName
instance.null
is returned if vname
is
null
.public static <T> List<T> unmodifiableList(List<T> src)
T
- The type of elements in the list.src
- The source list.src
is null
.public static <T> Set<T> unmodifiableSet(Set<T> src)
T
- The type of elements in the set.src
- The source set.src
is null
.public static <T> Set<T> unmodifiableKeySet(Map<T,?> src)
T
- The type of keys in the map.src
- The source map.src
is null
.public static org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId getVlanId(VtnVlanIdField field) throws RpcException
VtnVlanIdField
instance.field
- A VtnVlanIdField
instance.VlanId
instance.RpcException
- field
contains an invalid value.public static boolean isBadRequest(Throwable t)
t
- A throwable to be tested.true
only if the given throwable is caused by a
bad user request.public static <T> List<T> toValueList(Map<?,T> map)
T
- The type of values in the given map.map
- A map to be converted.null
if the given map is null
or empty.public static boolean isEmpty(Collection<?> c)
c
- A collection to be tested.true
only of the given collection is empty.public static VnodeState toVnodeState(boolean b)
VnodeState
instance.b
- A boolean value.VnodeState.UP
if b
is true
.
VnodeState.DOWN
if b
is false
.public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress verify(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress mac) throws RpcException
mac
- The MAC address to be tested.RpcException
- The given MAC address is invalid.Copyright © 2018 OpenDaylight. All rights reserved.