Package jsonvalues
Interface ImmutableSeq
-
public interface ImmutableSeq
Represents an immutable data structure where elements of a JsArray are stored. Each immutable Json factoryImmutableJsons
has an implementation of this interface, that can be defined using the methodImmutableJsons.withSeq(Class)
. The default immutable implementation thatJsons.immutable
uses is the immutable Scala Vector.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description V
add(int index, JsElem ele)
adds an element at the index, shifting elements at greater or equal indexes one position to the right.V
appendBack(JsElem elem)
appends the element to the back of the seqV
appendFront(JsElem elem)
appends the element to the front of the seqboolean
contains(JsElem e)
returns true if the seq contains the elementV
empty()
returns an empty seq of the same typeM
emptyObject()
returns an empty map.JsElem
get(int index)
returns the element located at the index.JsElem
head()
returns the first element of the seq.V
init()
boolean
isEmpty()
returns true if this seq is emptyJsElem
last()
returns the last element of the seq.V
remove(int index)
removes the element located at the index.int
size()
returns the size of the seqV
tail()
V
update(int index, JsElem ele)
updates the element located at the index with a new element.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
head
JsElem head()
returns the first element of the seq. It's called by the library only if the seq is not empty- Returns:
- the first element of the seq
-
tail
V tail()
-
init
V init()
-
last
JsElem last()
returns the last element of the seq. It's called by the library only if the seq is not empty- Returns:
- the last element of the seq
-
get
JsElem get(int index)
returns the element located at the index. It's called by the library only if the index exists- Parameters:
index
- the given index- Returns:
- the element located at the index
-
size
int size()
returns the size of the seq- Returns:
- the size of the seq
-
isEmpty
boolean isEmpty()
returns true if this seq is empty- Returns:
- true if empty, false otherwise
-
contains
boolean contains(JsElem e)
returns true if the seq contains the element- Parameters:
e
- the given element- Returns:
- true if the seq contains the element, false otherwise
-
empty
V empty()
returns an empty seq of the same type- Returns:
- an empty seq of the same type
-
appendFront
V appendFront(JsElem elem)
appends the element to the front of the seq- Parameters:
elem
- the given element- Returns:
- a seq
-
appendBack
V appendBack(JsElem elem)
appends the element to the back of the seq- Parameters:
elem
- the given element- Returns:
- a seq
-
update
V update(int index, JsElem ele)
updates the element located at the index with a new element. It will be called by the library only if the index exists- Parameters:
index
- the given indexele
- the given element- Returns:
- an updated seq
-
add
V add(int index, JsElem ele)
adds an element at the index, shifting elements at greater or equal indexes one position to the right. It's called by the library only if the index exists- Parameters:
index
- the given indexele
- the given element- Returns:
- a seq
-
remove
V remove(int index)
removes the element located at the index. It will be called by the library only if the index exists- Parameters:
index
- the given index- Returns:
- a seq with the element located at the index removed
-
emptyObject
M emptyObject()
returns an empty map. Every data structure defined to model a Json array has its dual to model a Json object and has to be defined when creating a Json factory.- Returns:
- en empty map of the dual data structure to model JsObj
-
-