CookbookUtils { public static boolean enumHasValue(Cookbook cookbook, String enumName, String value) { return CookbookUtils.isEnumType(cookbook, enumName) && cookbook.getEnums().stream() .filter(e -> e.getName().equals(enumName)) .collect(Collectors.toList()) .get(0) .getValues() .contains(value); }  static boolean isPrimitiveType(String type); static boolean isFlagType(String flag); static boolean isKnownType(Cookbook cookbook, String type); static boolean isEnumType(Cookbook cookbook, String name); static boolean enumHasValue(Cookbook cookbook, String enumName, String value); static boolean isPrimitiveType(Type type); static boolean isNonPrimitive(String type, Cookbook cookbook); static Set<String> getNonPrimitiveTypes(Ingredient ingredient, Cookbook cookbook); static String getBaseType(String type, Cookbook cookbook); static ParamType parseType(String type, Cookbook cookbook);  }
@Test public void testEnumHasValue_hasValue() { List<Enum> enums = new ArrayList<>(); List<String> enumValues = new ArrayList<>(); enumValues.add("A"); enumValues.add("B"); enums.add(new Enum("MyEnum", enumValues)); Cookbook cookbook = new Cookbook("test", new ArrayList<>(), enums); assertTrue(CookbookUtils.enumHasValue(cookbook, "MyEnum", "A")); }
@Test public void testEnumHasValue_unknownValue() { List<Enum> enums = new ArrayList<>(); List<String> enumValues = new ArrayList<>(); enumValues.add("A"); enumValues.add("B"); enums.add(new Enum("MyEnum", enumValues)); Cookbook cookbook = new Cookbook("test", new ArrayList<>(), enums); assertFalse(CookbookUtils.enumHasValue(cookbook, "MyEnum", "C")); }