org.springframework.integration.util
Class UUIDConverter
java.lang.Object
org.springframework.integration.util.UUIDConverter
- All Implemented Interfaces:
- Converter<Object,UUID>
public class UUIDConverter
- extends Object
- implements Converter<Object,UUID>
Utility to help generate UUID instances from generic objects.
- Author:
- Dave Syer
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_CHARSET
public static final String DEFAULT_CHARSET
- See Also:
- Constant Field Values
UUIDConverter
public UUIDConverter()
convert
public UUID convert(Object source)
- Convert the input to a UUID using the convenience method
getUUID(Object)
.
- Specified by:
convert
in interface Converter<Object,UUID>
- See Also:
Converter.convert(java.lang.Object)
getUUID
public static UUID getUUID(Object input)
- Convenient utility to convert an object to a UUID. If the input is
- null: returns null
- a UUID: returns the input unchanged
- a String formatted as a UUID: returns the result of
UUID.fromString(String)
- any other String: returns
UUID.nameUUIDFromBytes(byte[])
with
bytes generated from the input
- a primitive or primitive wrapper: converts to a String ans then uses
the previous conversion method
- Serializable: returns the
UUID.nameUUIDFromBytes(byte[])
with
the serialized bytes of the input
If none of the above applies there will be an exception trying to serialize.
- Parameters:
input
- an Object
- Returns:
- a UUID constructed from the input
Copyright © 2010. All Rights Reserved.