Package org.mozilla.zest.core.v1
Class ZestLoopState<T>
- java.lang.Object
-
- org.mozilla.zest.core.v1.ZestElement
-
- org.mozilla.zest.core.v1.ZestLoopState<T>
-
- Type Parameters:
T- the generic type
- Direct Known Subclasses:
ZestLoopStateInteger,ZestLoopStateString
public abstract class ZestLoopState<T> extends ZestElement
This class represents a state of the loop.
-
-
Field Summary
-
Fields inherited from class org.mozilla.zest.core.v1.ZestElement
JSON_ELEMENT_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedZestLoopState()Instantiates a new zest loop state.protectedZestLoopState(ZestLoopTokenSet<T> initializationTokenSet)main construptor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ZestLoopState<T>deepCopy()Deep copy.booleanequals(Object obj)intgetCurrentIndex()returns the current index of the current token considered inside the loop.TgetCurrentToken()returns the current token considered inside the loop.inthashCode()protected abstract booleanincrease(ZestLoopTokenSet<T> set)this increase the state and goes to the next state.protected voidincreaseIndex()Increase loops indexes.booleanisLastState(ZestLoopTokenSet<T> set)Checks if is last state.protected TsetCurrentToken(T newToken)Sets the current token.protected voidsetIndex(int newIndex)Sets the index.voidtoLastState(ZestLoopTokenSet<T> set)this sets the state to the last state: i.e.-
Methods inherited from class org.mozilla.zest.core.v1.ZestElement
getElementType, isSameSubclass, setElementType
-
-
-
-
Constructor Detail
-
ZestLoopState
protected ZestLoopState()
Instantiates a new zest loop state.
-
ZestLoopState
protected ZestLoopState(ZestLoopTokenSet<T> initializationTokenSet)
main construptor.- Parameters:
initializationTokenSet- the set of token and the fisrt value to consider inside the loop
-
-
Method Detail
-
getCurrentToken
public T getCurrentToken()
returns the current token considered inside the loop.- Returns:
- the current token considered inside the loop
-
setCurrentToken
protected T setCurrentToken(T newToken)
Sets the current token.- Parameters:
newToken- the new token- Returns:
- the previous token
-
getCurrentIndex
public int getCurrentIndex()
returns the current index of the current token considered inside the loop.- Returns:
- the index of the current token considered in the loop
-
increaseIndex
protected void increaseIndex()
Increase loops indexes.
-
setIndex
protected void setIndex(int newIndex)
Sets the index.- Parameters:
newIndex- the new index
-
increase
protected abstract boolean increase(ZestLoopTokenSet<T> set)
this increase the state and goes to the next state.- Parameters:
set- the set
-
toLastState
public void toLastState(ZestLoopTokenSet<T> set)
this sets the state to the last state: i.e. the loop has finished- Parameters:
set- the set
-
deepCopy
public abstract ZestLoopState<T> deepCopy()
Description copied from class:ZestElementDeep copy.- Specified by:
deepCopyin classZestElement- Returns:
- the zest element
-
isLastState
public boolean isLastState(ZestLoopTokenSet<T> set)
Checks if is last state.- Parameters:
set- the set- Returns:
- true, if is last state
-
-