Package org.apache.juneau.reflect
Class Mutaters
java.lang.Object
org.apache.juneau.reflect.Mutaters
Cache of object that convert POJOs to and from common types such as strings, readers, and input streams.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a transform for the specified input/output types.static <T> TfromString(Class<T> c, String s) Constructs a new instance of the specified class from the specified string.static <I,O> Mutater<I, O> Returns the transform for converting the specified input type to the specified output type.static <I,O> boolean Returns the transform for converting the specified input type to the specified output type.static StringConverts an object to a string.
-
Field Details
-
NULL
Represents a non-existent transform.
-
-
Constructor Details
-
Mutaters
public Mutaters()
-
-
Method Details
-
add
Adds a transform for the specified input/output types.- Parameters:
ic- The input type.oc- The output type.t- The transform for converting the input to the output.
-
fromString
Constructs a new instance of the specified class from the specified string.Class must be one of the following:
- Have a public constructor that takes in a single
String argument. - Have a static
fromString(String) (or related) method. - Be an
enum .
- Type Parameters:
T- The class type.- Parameters:
c- The class type.s- The string to create the instance from.- Returns:
- A new object instance, or
null if a method for converting the string to an object could not be found.
- Have a public constructor that takes in a single
-
get
Returns the transform for converting the specified input type to the specified output type.- Type Parameters:
I- The input type.O- The output type.- Parameters:
ic- The input type.oc- The output type.- Returns:
- The transform for performing the conversion, or
null if the conversion cannot be made.
-
hasMutate
Returns the transform for converting the specified input type to the specified output type.- Type Parameters:
I- The input type.O- The output type.- Parameters:
ic- The input type.oc- The output type.- Returns:
- The transform for performing the conversion, or
null if the conversion cannot be made.
-
toString
Converts an object to a string.Normally, this is just going to call
toString() on the object. However, theLocaleandTimeZoneobjects are treated special so that the returned value works with thefromString(Class, String)method.- Parameters:
o- The object to convert to a string.- Returns:
- The stringified object, or
null if the object wasnull .
-