Class Json.DefaultFactory
- java.lang.Object
-
- org.infinispan.commons.dataconversion.internal.Json.DefaultFactory
-
- All Implemented Interfaces:
Json.Factory
- Enclosing class:
- Json
public static class Json.DefaultFactory extends Object implements Json.Factory
-
-
Constructor Summary
Constructors Constructor Description DefaultFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Json
array()
Construct and return a JSON object.Json
bool(boolean x)
Construct and return a JSON boolean.Json
make(Object anything)
Construct and return a JSON object.Json
nil()
Construct and return an object representing JSONnull
.Json
number(Number x)
Construct and return a JSON number.Json
object()
Construct and return a JSON object.Json
raw(String x)
Json
string(String x)
Construct and return a JSON string.
-
-
-
Method Detail
-
nil
public Json nil()
Description copied from interface:Json.Factory
Construct and return an object representing JSONnull
. Implementations are free to cache a return the same instance. The resulting value must returntrue
fromisNull()
andnull
fromgetValue()
.- Specified by:
nil
in interfaceJson.Factory
- Returns:
- The representation of a JSON
null
value.
-
bool
public Json bool(boolean x)
Description copied from interface:Json.Factory
Construct and return a JSON boolean. The resulting value must returntrue
fromisBoolean()
and the passed in parameter fromgetValue()
.- Specified by:
bool
in interfaceJson.Factory
- Parameters:
x
- The boolean value.- Returns:
- A JSON with
isBoolean() == true
. Implementations are free to cache and return the same instance for true and false.
-
string
public Json string(String x)
Description copied from interface:Json.Factory
Construct and return a JSON string. The resulting value must returntrue
fromisString()
and the passed in parameter fromgetValue()
.- Specified by:
string
in interfaceJson.Factory
- Parameters:
x
- The string to wrap as a JSON value.- Returns:
- A JSON element with the given string as a value.
-
raw
public Json raw(String x)
- Specified by:
raw
in interfaceJson.Factory
-
number
public Json number(Number x)
Description copied from interface:Json.Factory
Construct and return a JSON number. The resulting value must returntrue
fromisNumber()
and the passed in parameter fromgetValue()
.- Specified by:
number
in interfaceJson.Factory
- Parameters:
x
- The numeric value.- Returns:
- Json instance representing that value.
-
array
public Json array()
Description copied from interface:Json.Factory
Construct and return a JSON object. The resulting value must returntrue
fromisArray()
and an implementation ofjava.util.List
fromgetValue()
.- Specified by:
array
in interfaceJson.Factory
- Returns:
- An empty JSON array.
-
object
public Json object()
Description copied from interface:Json.Factory
Construct and return a JSON object. The resulting value must returntrue
fromisObject()
and an implementation ofjava.util.Map
fromgetValue()
.- Specified by:
object
in interfaceJson.Factory
- Returns:
- An empty JSON object.
-
make
public Json make(Object anything)
Description copied from interface:Json.Factory
Construct and return a JSON object. The resulting value can be of any JSON type. The method is responsible for examining the type of its argument and performing an appropriate mapping to aJson
instance.- Specified by:
make
in interfaceJson.Factory
- Parameters:
anything
- An arbitray Java object from which to construct aJson
element.- Returns:
- The newly constructed
Json
instance.
-
-