Package com.gengoai.parsing
Class ListExpression
- java.lang.Object
-
- com.gengoai.parsing.BaseExpression
-
- com.gengoai.parsing.ListExpression
-
- All Implemented Interfaces:
Expression
,Serializable
,Iterable<Expression>
public class ListExpression extends BaseExpression implements Iterable<Expression>
The type List expression.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ListExpression(Tag type, Collection<Expression> expressions, String separator, String startOfList, String endOfList)
Instantiates a new List expression.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends Expression>
List<E>elementsAs(Class<E> eClass)
Generates the list of elements casting them to the desired expression typeExpression
get(int index)
Get expression.static PrefixHandler
handler(Tag startOfListTag, Tag endOfListTag, Tag separatorTag, String startOfListStr, String endOfListStr, String separatorStr)
Handler prefix handler.boolean
isEmpty()
Checks if there no expressions in the listIterator<Expression>
iterator()
int
numberOfExpressions()
Number of expressions int.Stream<Expression>
stream()
Streams the elements.<E extends Expression>
Stream<Expression>stream(Class<E> eClass)
Streams the elements as the given type.String
toString()
-
Methods inherited from class com.gengoai.parsing.BaseExpression
getType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.gengoai.parsing.Expression
apply, as, isInstance, isInstance, isInstance, when, when
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ListExpression
public ListExpression(Tag type, Collection<Expression> expressions, String separator, String startOfList, String endOfList)
Instantiates a new List expression.- Parameters:
type
- the typeexpressions
- the expressions
-
-
Method Detail
-
handler
public static PrefixHandler handler(Tag startOfListTag, Tag endOfListTag, Tag separatorTag, String startOfListStr, String endOfListStr, String separatorStr)
Handler prefix handler.- Parameters:
startOfListTag
- the operatorendOfListTag
- the end of listseparatorTag
- the separator- Returns:
- the prefix handler
-
get
public Expression get(int index)
Get expression.- Parameters:
index
- the index- Returns:
- the expression
-
iterator
public Iterator<Expression> iterator()
- Specified by:
iterator
in interfaceIterable<Expression>
-
numberOfExpressions
public int numberOfExpressions()
Number of expressions int.- Returns:
- the int
-
isEmpty
public boolean isEmpty()
Checks if there no expressions in the list- Returns:
- True if the list of expressions is empty
-
elementsAs
public <E extends Expression> List<E> elementsAs(Class<E> eClass)
Generates the list of elements casting them to the desired expression type- Type Parameters:
E
- the expression type parameter- Parameters:
eClass
- the expression class- Returns:
- the list of expression as the given type
-
stream
public Stream<Expression> stream()
Streams the elements.- Returns:
- the stream of elements
-
stream
public <E extends Expression> Stream<Expression> stream(Class<E> eClass)
Streams the elements as the given type.- Type Parameters:
E
- the expression type parameter- Parameters:
eClass
- the expression class- Returns:
- the stream of elements as the given type
-
-