Package jsonvalues
Class ImmutableJsons.ImmutableJsArrays
- java.lang.Object
-
- jsonvalues.ImmutableJsons.ImmutableJsArrays
-
- Enclosing class:
- ImmutableJsons
public class ImmutableJsons.ImmutableJsArrays extends Object
represents a factory of immutable Json arrays
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsArray
empty()
Returns the immutable empty array.JsArray
of(boolean bool, boolean... others)
Returns an immutable array from one or more booleans.JsArray
of(double number, double... others)
Returns an immutable array from one or more doubles.JsArray
of(int number, int... others)
Returns an immutable array from one or more integers.JsArray
of(long number, long... others)
Returns an immutable array from one or more longs.JsArray
of(String str, String... others)
Returns an immutable array from one or more strings.JsArray
of(JsElem e)
JsArray
of(JsElem e, JsElem e1)
Returns an immutable two-element array.JsArray
of(JsElem e, JsElem e1, JsElem e2)
Returns an immutable three-element array.JsArray
of(JsElem e, JsElem e1, JsElem e2, JsElem e3)
Returns an immutable four-element array.JsArray
of(JsElem e, JsElem e1, JsElem e2, JsElem e3, JsElem e4)
Returns an immutable five-element array.JsArray
of(JsElem e, JsElem e1, JsElem e2, JsElem e3, JsElem e4, JsElem... rest)
Returns an immutable array.JsArray
of(JsPair pair, JsPair... others)
Returns an immutable array from one or more pairs.JsArray
ofIterable(Iterable<JsElem> iterable)
returns an immutable json array from an iterable of json elementsTryArr
parse(String str)
Tries to parse the string into an immutable json array.TryArr
parse(String str, ParseBuilder builder)
JsArray
toImmutable(JsArray mutable)
-
-
-
Method Detail
-
empty
public JsArray empty()
Returns the immutable empty array. The same instance is always returned.- Returns:
- the singleton immutable empty JsArray
-
of
public JsArray of(JsPair pair, JsPair... others)
Returns an immutable array from one or more pairs.- Parameters:
pair
- a pairothers
- more optional pairs- Returns:
- an immutable JsArray
- Throws:
UserError
- if an elem of a pair is mutable
-
of
public JsArray of(JsElem e, JsElem e1)
Returns an immutable two-element array.- Parameters:
e
- a JsEleme1
- a JsElem- Returns:
- an immutable two-element JsArray
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsArray of(JsElem e, JsElem e1, JsElem e2)
Returns an immutable three-element array.- Parameters:
e
- a JsEleme1
- a JsEleme2
- a JsElem- Returns:
- an immutable three-element JsArray
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsArray of(JsElem e, JsElem e1, JsElem e2, JsElem e3)
Returns an immutable four-element array.- Parameters:
e
- a JsEleme1
- a JsEleme2
- a JsEleme3
- a JsElem- Returns:
- an immutable four-element JsArray
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsArray of(JsElem e, JsElem e1, JsElem e2, JsElem e3, JsElem e4)
Returns an immutable five-element array.- Parameters:
e
- a JsEleme1
- a JsEleme2
- a JsEleme3
- a JsEleme4
- a JsElem- Returns:
- an immutable five-element JsArray
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsArray of(JsElem e, JsElem e1, JsElem e2, JsElem e3, JsElem e4, JsElem... rest)
Returns an immutable array.- Parameters:
e
- a JsEleme1
- a JsEleme2
- a JsEleme3
- a JsEleme4
- a JsElemrest
- more optional JsElem- Returns:
- an immutable JsArray
- Throws:
UserError
- if an elem is a mutable Json
-
ofIterable
public JsArray ofIterable(Iterable<JsElem> iterable)
returns an immutable json array from an iterable of json elements- Parameters:
iterable
- the iterable of json elements- Returns:
- an immutable json array
-
of
public JsArray of(String str, String... others)
Returns an immutable array from one or more strings.- Parameters:
str
- a stringothers
- more optional strings- Returns:
- an immutable JsArray
-
of
public JsArray of(int number, int... others)
Returns an immutable array from one or more integers.- Parameters:
number
- an integerothers
- more optional integers- Returns:
- an immutable JsArray
-
of
public JsArray of(boolean bool, boolean... others)
Returns an immutable array from one or more booleans.- Parameters:
bool
- an booleanothers
- more optional booleans- Returns:
- an immutable JsArray
-
of
public JsArray of(long number, long... others)
Returns an immutable array from one or more longs.- Parameters:
number
- a longothers
- more optional longs- Returns:
- an immutable JsArray
-
of
public JsArray of(double number, double... others)
Returns an immutable array from one or more doubles.- Parameters:
number
- a doubleothers
- more optional doubles- Returns:
- an immutable JsArray
-
parse
public TryArr parse(String str)
Tries to parse the string into an immutable json array.- Parameters:
str
- the string to be parsed- Returns:
- a
TryArr
computation
-
parse
public TryArr parse(String str, ParseBuilder builder)
-
-