StatSet getIntegerList rework and addition of setIntegerList.

This commit is contained in:
MobiusDevelopment
2021-09-19 13:20:41 +00:00
parent c3889a0039
commit ad08f1081a
43 changed files with 974 additions and 566 deletions

View File

@ -392,16 +392,50 @@ public class StatSet implements IParserAdvUtils
return result;
}
public List<Integer> getIntegerList(String key, String splitOn)
public List<Integer> getIntegerList(String key)
{
final List<Integer> result = new ArrayList<>();
for (int i : getIntArray(key, splitOn))
final String val = getString(key, null);
final List<Integer> result;
if (val != null)
{
result.add(i);
final String[] splitVal = val.split(",");
result = new ArrayList<>(splitVal.length + 1);
for (String split : splitVal)
{
result.add(Integer.parseInt(split));
}
}
else
{
result = new ArrayList<>(1);
}
return result;
}
public void setIntegerList(String key, List<Integer> list)
{
if (key == null)
{
return;
}
if ((list == null) || list.isEmpty())
{
remove(key);
return;
}
final StringBuilder sb = new StringBuilder();
for (int element : list)
{
sb.append(element);
sb.append(",");
}
sb.deleteCharAt(sb.length() - 1); // Prettify value.
set(key, sb.toString());
}
@Override
public long getLong(String key)
{