We have to move either forward or backwards with newparse #4441
This commit is contained in:
parent
18a92a958c
commit
72292e561a
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue