We have to move either forward or backwards with newparse #4441

This commit is contained in:
rusefillc 2023-06-16 14:59:34 -04:00
parent 18a92a958c
commit 72292e561a
2 changed files with 2 additions and 20 deletions

View File

@ -55,16 +55,13 @@ public class ParseState implements DefinitionsState {
switch (existingDefinition.overwritePolicy) {
case NotAllowed:
throw new IllegalStateException("Tried to add definition for " + name + ", but one already existed.");
case Replace:
definitions.remove(name);
break;
case IgnoreNew:
// ignore the new definition, do nothing
return;
}
}
definitions.put(name, new Definition(name, value, overwritePolicy));
definitions.put(name, new Definition(value, overwritePolicy));
}
private void addDefinition(String name, Object value) {

View File

@ -1,34 +1,19 @@
package com.rusefi.newparse.parsing;
public class Definition {
public final String name;
public final Object value;
public final OverwritePolicy overwritePolicy;
public enum OverwritePolicy {
NotAllowed,
Replace,
IgnoreNew
}
public Definition(String name, Object value, OverwritePolicy overwritePolicy) {
this.name = name;
public Definition(Object value, OverwritePolicy overwritePolicy) {
this.value = value;
this.overwritePolicy = overwritePolicy;
}
public boolean isNumeric() {
return this.value instanceof Double || this.value instanceof Integer;
}
public double asDouble() {
if (this.value instanceof Double) {
return ((Double)this.value);
} else {
return ((Integer)this.value).doubleValue();
}
}
@Override
public String toString() {
return this.value.toString();