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) {
|
switch (existingDefinition.overwritePolicy) {
|
||||||
case NotAllowed:
|
case NotAllowed:
|
||||||
throw new IllegalStateException("Tried to add definition for " + name + ", but one already existed.");
|
throw new IllegalStateException("Tried to add definition for " + name + ", but one already existed.");
|
||||||
case Replace:
|
|
||||||
definitions.remove(name);
|
|
||||||
break;
|
|
||||||
case IgnoreNew:
|
case IgnoreNew:
|
||||||
// ignore the new definition, do nothing
|
// ignore the new definition, do nothing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
definitions.put(name, new Definition(name, value, overwritePolicy));
|
definitions.put(name, new Definition(value, overwritePolicy));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDefinition(String name, Object value) {
|
private void addDefinition(String name, Object value) {
|
||||||
|
|
|
@ -1,34 +1,19 @@
|
||||||
package com.rusefi.newparse.parsing;
|
package com.rusefi.newparse.parsing;
|
||||||
|
|
||||||
public class Definition {
|
public class Definition {
|
||||||
public final String name;
|
|
||||||
public final Object value;
|
public final Object value;
|
||||||
public final OverwritePolicy overwritePolicy;
|
public final OverwritePolicy overwritePolicy;
|
||||||
|
|
||||||
public enum OverwritePolicy {
|
public enum OverwritePolicy {
|
||||||
NotAllowed,
|
NotAllowed,
|
||||||
Replace,
|
|
||||||
IgnoreNew
|
IgnoreNew
|
||||||
}
|
}
|
||||||
|
|
||||||
public Definition(String name, Object value, OverwritePolicy overwritePolicy) {
|
public Definition(Object value, OverwritePolicy overwritePolicy) {
|
||||||
this.name = name;
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.overwritePolicy = overwritePolicy;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.value.toString();
|
return this.value.toString();
|
||||||
|
|
Loading…
Reference in New Issue