public interface Object_To_StrBuilder extends IsTransformer<Object,StrBuilder>
A null-safe transformer that takes an object and tries return a StrBuilder using various strategies.
The object is processed as follows:
test object for being null, throw null pointer exception if that’s the case
test if object implements HasText, take the text
test if object implements HasTextCluster, take the cluster and add each element to the text
test if object is an ST, render and take rendered text
test if object implements DoesRender, take the rendered text
test if object implements DoesRenderToWidth, take the rendered text
test if object implements RendersToCluster, take the rendered cluster and add as text
test if object implements RendersToClusterWidth, take the rendered cluster and add as text
test if object is an Iterator, iterate and call this method for each member
test if object is an Iterable, iterate and call this method for each member
test if object is an array of something, iterate the array and call this method for each member
use the object as is (which will take a string if it is a string, use the toString() method otherwise).
Null objects in clusters are silently ignored. Blank strings are processed like any other string (they do not impact the text anyway).
The method is recursive for iterators, iterables, and arrays. Care needs to be taken that the provided clusters do not lead to endless loops.
| Modifier and Type | Method and Description |
|---|---|
static StrBuilder |
convert(Object obj)
Transforms an object to a string builder.
|
static Object_To_StrBuilder |
create()
Creates a transformer that takes an object and returns a string builder.
|
default StrBuilder |
transform(Object obj)
Transforms an object to a string builder.
|
default StrBuilder |
transform(Object obj,
StrBuilder sb)
Transforms an object to a string builder using the given builder.
|
apply, transformdefault StrBuilder transform(Object obj)
Transforms an object to a string builder.
transform in interface Transformer<Object,StrBuilder>obj - input objectdefault StrBuilder transform(Object obj, StrBuilder sb)
Transforms an object to a string builder using the given builder.
obj - input objectsb - a given builder, new builder will be created if nullstatic Object_To_StrBuilder create()
Creates a transformer that takes an object and returns a string builder.
interface description for how the converter worksstatic StrBuilder convert(Object obj)
Transforms an object to a string builder.
obj - input objectinterface description for how the convertion worksCopyright © 2016–2017. All rights reserved.