@Override public Object defaultValue(Type type) { type = type.getOriginType(); if (is(type, VOID)) { return null; } if (is(type, INTEGER)) { return new Long(0); } if (is(type, REAL)) { return new Double(0.0); } if (is(type, BOOLEAN)) { return Boolean.FALSE; } if (is(type, STRING)) { return new String(""); } List<Type> superTypes = typeSystem.getSuperTypes(type); if (!superTypes.isEmpty()) return defaultValue(superTypes.get(0)); throw new IllegalArgumentException("Unknown type " + type); }
protected boolean is(Type type, String typeName) { return typeSystem.isSame(type, typeSystem.getType(typeName)); }