|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jplate.foundation.util.ComputeData
public final class ComputeData
Computes values based on an initial values and a default values: if the initial value is null, the default value is returned.
Consider the following examples:someFoo
is
defined and DEFAULT_FOO
represents a "default" instance):
final Foo myFoo = ComputeDataValue ( someFoo, DEFAULT_FOO );Above, if
someFoo == null
, myFoo
will now
equal DEFAULT_FOO
. Otherwise, myFoo
will
equal someFoo
.
someString
is defined):
final static String DEFAULT_STR = "Alpha"; ... final String myString = ComputeString ( someString, DEFAULT_STR );Above, if
someString == null
, myString
will
equal DEFAULT_STR
. Otherwise, myString
will
equal someString
.
Modifications: $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $ $Revision: 479 $ $Author: sfloess $ $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/util/ComputeData.java $
Constructor Summary | |
---|---|
private |
ComputeData()
Default constructor not allowed. |
Method Summary | ||
---|---|---|
static java.lang.String |
computeString(java.lang.String str,
java.lang.String defaultStr)
Computes a string value. |
|
static
|
computeValue(V value,
V defaultValue)
Returns value if value is not null or
defaultValue if it is. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private ComputeData()
java.lang.UnsupportedOperationException
- if this constructor is called.Method Detail |
---|
public static <V> V computeValue(V value, V defaultValue)
value
if value
is not null or
defaultValue
if it is.
value
- The object to examine for null.defaultValue
- The return value if value
is null.
value
if value
is not null or
defaultValue
if it is.public static java.lang.String computeString(java.lang.String str, java.lang.String defaultStr)
str
is null or blank, it will
return defaultStr
otherwise it returns str
.
str
- The string to examine for null/blank.defaultStr
- The default string to return if str
is null
or blank.
defaultStr
if str
is null/empty otherwise
str
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |