/** * Obtains an instance from the specified unique name. * * @param uniqueName the unique name * @return the index * @throws IllegalArgumentException if the name is not known */ @FromString public static Index of(String uniqueName) { ArgChecker.notNull(uniqueName, "uniqueName"); return Indices.ENUM_LOOKUP.lookup(uniqueName); }
public static UberNamed of(String name) { return CombinedExtendedEnum.of(UberNamed.class).lookup(name); }
public void test_lookup() { assertEquals(UberNamed.of("Standard"), SampleNameds.STANDARD); assertEquals(UberNamed.of("More"), MoreSampleNameds.MORE); CombinedExtendedEnum<UberNamed> combined = CombinedExtendedEnum.of(UberNamed.class); assertEquals(combined.find("Rubbish"), Optional.empty()); assertThrows(IllegalArgumentException.class, () -> combined.lookup("Rubbish")); assertEquals(combined.toString(), "CombinedExtendedEnum[UberNamed]"); }