/** * Get all non deprecated values */ public static ResourceType[] getValues() { return Arrays.stream(ResourceType.values()) .filter(r -> !r.deprecated) .toArray(ResourceType[]::new); }
public static String getAllTypesAsString() { return Arrays.stream(ResourceType.values()) .filter(r -> !r.deprecated) .map(Object::toString) .collect(Collectors.joining(", ")); }
public static ResourceType fromName(String name) { if (name == null || "".equals(name)) { throw new LocalizableValidationException("Name cannot be null or empty!", "common.resource-type.name.empty"); } for (ResourceType r : ResourceType.values()) { if (r.name.equals(name) && !r.deprecated) { return r; } } throw new LocalizableValidationException("No matching type for:" + name, "common.resource-type.name.mismatch", name); }
public static ResourceType fromContentType(String contentType) { if (contentType == null || "".equals(contentType)) { throw new LocalizableValidationException("ContentType cannot be null or empty!", "common.resource-type.content-type.empty"); } for (ResourceType r : ResourceType.values()) { if (r.contentType.equals(contentType) && !r.deprecated) { return r; } } throw new LocalizableValidationException("No matching type for:" + contentType, "common.resource-type.content-type.mismatch", contentType); }