value = numberToLiteral((Integer) value); value = numberToLiteral((Double) value);
public void setPropertyValue(String name, Object value){ int index = names.indexOf(name); if (index != -1){ GlyphProperty prop = (GlyphProperty) list.get(index); if (value instanceof String){ value = stringToLiteral((String) value); } if (value instanceof Integer){ value = numberToLiteral((Integer) value); } if (value instanceof Double){ value = numberToLiteral((Double) value); } if (prop.getType().isAssignableFrom(value.getClass())){ prop.setValue(value); } else { throw new RuntimeException("Wrong class for setting variable " + name + ". Expected a " + prop.getType() + " but received a " + value.getClass() + "."); } } else { throw new RuntimeException("Tried to set the value of a non-existent property: " + name); } } }
public void setPropertyValue(String name, Object value){ int index = names.indexOf(name); if (index != -1){ GlyphProperty prop = (GlyphProperty) list.get(index); if (value instanceof String){ value = stringToLiteral((String) value); } if (value instanceof Integer){ value = numberToLiteral((Integer) value); } if (value instanceof Double){ value = numberToLiteral((Double) value); } if (prop.getType().isAssignableFrom(value.getClass())){ prop.setValue(value); } else { throw new RuntimeException("Wrong class for setting variable " + name + ". Expected a " + prop.getType() + " but received a " + value.getClass() + "."); } } else { throw new RuntimeException("Tried to set the value of a non-existent property: " + name); } } }