Use newer Java features in places where it makes sense and more (#1009)

This commit is contained in:
altrisi authored and GitHub committed 2021-08-03 07:32:40 -03:00
1 parent 28cb136c6b
commit 7fb5e47da5
34 files changed
+338 -399

No files matched your search

@@ -120,6 +120,8 @@ public class NumericValue extends Value
}
return super.add(v);
}
@Override
public Value subtract(Value v) { // TODO test if definintn add(NumericVlaue) woud solve the casting
if (v instanceof NumericValue nv)
{
@@ -131,6 +133,8 @@ public class NumericValue extends Value
}
return super.subtract(v);
}
@Override
public Value multiply(Value v)
{
if (v instanceof NumericValue nv)
@@ -147,6 +151,8 @@ public class NumericValue extends Value
}
return new StringValue(StringUtils.repeat(v.getString(), (int) getLong()));
}
@Override
public Value divide(Value v)
{
//if (1+2==3) throw new ArithmeticException("Booyah");
@@ -223,17 +229,6 @@ public class NumericValue extends Value
this.value = (double)value;
}
/**
* Creates a legacy {@link NumericValue} for a {@code boolean}.
* @param boolval The boolean to set 1 or 0 for this {@link NumericValue}
* @deprecated Use {@link BooleanValue#of(boolean)} instead
*/
@Deprecated
public NumericValue(boolean boolval)
{
this(boolval?1L:0L);
}
@Override
public int length()
{