/** * Obtains a combined extended enum instance. * <p> * Calling this method loads configuration files to determine which extended enums to combine. * The configuration file has the same simple name as the specified type and is a * {@linkplain IniFile INI file} with the suffix '.ini'. * * @param <R> the type of the enum * @param type the type to load * @return the extended enum */ public static <R extends Named> CombinedExtendedEnum<R> of(Class<R> type) { try { // load all matching files String name = type.getSimpleName() + ".ini"; IniFile config = ResourceConfig.combinedIniFile(name); // parse files ImmutableList<ExtendedEnum<? extends R>> children = parseChildren(config, type); log.fine(() -> "Loaded combined extended enum: " + name + ", providers: " + children); return new CombinedExtendedEnum<>(type, children); } catch (RuntimeException ex) { // logging used because this is loaded in a static variable log.severe("Failed to load CombinedExtendedEnum for " + type + ": " + Throwables.getStackTraceAsString(ex)); // return an empty instance to avoid ExceptionInInitializerError return new CombinedExtendedEnum<>(type, ImmutableList.of()); } }