org.rythmengine.toString
Class ToStringOption

java.lang.Object
  extended by org.rythmengine.toString.ToStringOption

public class ToStringOption
extends Object

Defines the options can be set when output an object into string


Field Summary
 boolean appendStatic
          Whether output static fields
 boolean appendTransient
          Whether output transient fields
static ToStringOption DEFAULT_OPTION
          The default option instance, with upToClassset to null, meaning up to Object root appendTransient set to false, will not output transient fields appendStatic set to false, will not output static fields
 Class<?> upToClass
          Specify the up most parent class whose declared fields will be output.
 
Constructor Summary
ToStringOption()
          Construct an new default option
ToStringOption(boolean appendStatic, boolean appendTransient)
          Construct an option with specified appendStatic and appendTransient switch.
ToStringOption(boolean appendStatic, boolean appendTransient, Class<?> upToClass)
          Construct an option with static, transient output switch and upToClass
 
Method Summary
 boolean equals(Object obj)
           
 int hashCode()
           
 ToStringOption setAppendStatic(boolean appendStatic)
          Return a ToStringOption instance with appendStatic option set.
 ToStringOption setAppendTransient(boolean appendTransient)
          Return a ToStringOption instance with appendTransient option set.
 ToStringOption setUpToClass(Class<?> c)
          Return a ToStringOption instance with upToClass option set.
 String toString()
          Print this to string option instance using the following logic:

static ToStringOption valueOf(String s)
          Construct a ToStringOption instance out from a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_OPTION

public static final ToStringOption DEFAULT_OPTION
The default option instance, with


upToClass

public Class<?> upToClass
Specify the up most parent class whose declared fields will be output. Default value is null, meaning all parent class declared fields will be output


appendTransient

public boolean appendTransient
Whether output transient fields


appendStatic

public boolean appendStatic
Whether output static fields

Constructor Detail

ToStringOption

public ToStringOption()
Construct an new default option

See Also:
DEFAULT_OPTION

ToStringOption

public ToStringOption(boolean appendStatic,
                      boolean appendTransient)
Construct an option with specified appendStatic and appendTransient switch.

Parameters:
appendStatic - when set to true the static fields will be output
appendTransient - when set to true the transient fields will be output

ToStringOption

public ToStringOption(boolean appendStatic,
                      boolean appendTransient,
                      Class<?> upToClass)
Construct an option with static, transient output switch and upToClass

Parameters:
appendStatic - when set to true the static fields will be output
appendTransient - when set to true the trasient fields will be output
upToClass - when set then the fields up to this parent class will be output, otherwise it will be up to Object root
Method Detail

setAppendTransient

public ToStringOption setAppendTransient(boolean appendTransient)
Return a ToStringOption instance with appendTransient option set. if the current instance is not default instance then set on the current instance and return the current instance. Otherwise, clone the default instance and set on the clone and return the clone

Parameters:
appendTransient -
Returns:
this option instance or clone if this is the DEFAULT_OPTION

setAppendStatic

public ToStringOption setAppendStatic(boolean appendStatic)
Return a ToStringOption instance with appendStatic option set. if the current instance is not default instance then set on the current instance and return the current instance. Otherwise, clone the default instance and set on the clone and return the clone

Parameters:
appendStatic -
Returns:
this option instance or clone if this is the DEFAULT_OPTION

setUpToClass

public ToStringOption setUpToClass(Class<?> c)
Return a ToStringOption instance with upToClass option set. if the current instance is not default instance then set on the current instance and return the current instance. Otherwise, clone the default instance and set on the clone and return the clone

Parameters:
c -
Returns:
this option instance or clone if this is the DEFAULT_OPTION

toString

public String toString()
Print this to string option instance using the following logic:


 return Rythm.toString(
    "{appendStatic: @_.appendStatic; " +
    "appendTransient: @_.appendTransient; " +
    upToClass: @_.upToClass?.getName()}", this);
 

Overrides:
toString in class Object
Returns:
String representation of this option

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

valueOf

public static ToStringOption valueOf(String s)
Construct a ToStringOption instance out from a string. The format of the String should be the same as the format output of toString() method

Parameters:
s -
Returns:
an option instance corresponding to the string specified


Copyright © 2013. All Rights Reserved.