Make split split lists in list of single elements list without delimiter
This commit is contained in:
3 files changed
+6
-2
No files matched your search
@@ -57,7 +57,7 @@ public class DataStructures {
|
||||
if (lv.size() == 1)
|
||||
{
|
||||
hwat = lv.get(0);
|
||||
delimiter = StringValue.EMPTY;
|
||||
delimiter = null;
|
||||
}
|
||||
else if (lv.size() == 2)
|
||||
{
|
||||
|
||||
@@ -355,7 +355,7 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|
||||
for (Value val : this.items)
|
||||
{
|
||||
index++;
|
||||
if (val.equals(delimiter))
|
||||
if (val.equals(delimiter) || delimiter == null)
|
||||
{
|
||||
result.items.add(ListValue.wrap(this.items.subList(startIndex, index-1)));
|
||||
startIndex = index;
|
||||
|
||||
@@ -193,6 +193,10 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
||||
|
||||
public Value split(Value delimiter)
|
||||
{
|
||||
if (delimiter == null)
|
||||
{
|
||||
delimiter = StringValue.EMPTY;
|
||||
}
|
||||
try
|
||||
{
|
||||
return ListValue.wrap(Arrays.stream(getString().split(delimiter.getString())).map(StringValue::new).collect(Collectors.toList()));
|
||||
|
||||
Reference in new issue
Block a user