static TypedName<?> parseAttribute(EntityDefaults entityDefaults, JsonNode col) { if (col.isNull() || col.isMissingNode()) { return null; } else if (col.isObject()) { String name = col.path("name").asText(null); String type = col.path("type").asText(null); Preconditions.checkArgument(name != null, "no attribute name specified"); Preconditions.checkArgument(type != null, "no attribute type specified"); return TypedName.create(name, type); } else if (col.isTextual()) { String name = col.asText(); TypedName<?> attr = entityDefaults != null ? entityDefaults.getAttributeDefaults(name) : null; if (attr == null) { attr = TypedName.create(col.asText(), col.asText().equals("id") ? (Class) Long.class : String.class); } return attr; } else { throw new IllegalArgumentException("invalid attribute specification: " + col.toString()); } } }
static TypedName<?> parseAttribute(EntityDefaults entityDefaults, JsonNode col) { if (col.isNull() || col.isMissingNode()) { return null; } else if (col.isObject()) { String name = col.path("name").asText(null); String type = col.path("type").asText(null); Preconditions.checkArgument(name != null, "no attribute name specified"); Preconditions.checkArgument(type != null, "no attribute type specified"); return TypedName.create(name, type); } else if (col.isTextual()) { String name = col.asText(); TypedName<?> attr = entityDefaults != null ? entityDefaults.getAttributeDefaults(name) : null; if (attr == null) { attr = TypedName.create(col.asText(), col.asText().equals("id") ? (Class) Long.class : String.class); } return attr; } else { throw new IllegalArgumentException("invalid attribute specification: " + col.toString()); } } }