/** * Look up the defaults for a particular entity type. * @param type The entity type. * @return The defaults. */ @Nullable public static EntityDefaults lookup(EntityType type) { // TODO Cache these defaults String name = type.getName(); String path = String.format("META-INF/lenskit/entity-defaults/%s.yaml", name); try (InputStream stream = ClassLoaders.inferDefault(EntityDefaults.class) .getResourceAsStream(path)) { if (stream == null) { return null; } ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); DefaultsBean bean = mapper.readValue(stream, DefaultsBean.class); return fromBean(type, bean); } catch (IOException e) { throw new UncheckedIOException("error defaults for " + type, e); } }
/** * Look up the defaults for a particular entity type. * @param type The entity type. * @return The defaults. */ @Nullable public static EntityDefaults lookup(EntityType type) { // TODO Cache these defaults String name = type.getName(); String path = String.format("META-INF/lenskit/entity-defaults/%s.yaml", name); try (InputStream stream = ClassLoaders.inferDefault(EntityDefaults.class) .getResourceAsStream(path)) { if (stream == null) { return null; } ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); DefaultsBean bean = mapper.readValue(stream, DefaultsBean.class); return fromBean(type, bean); } catch (IOException e) { throw new UncheckedIOException("error defaults for " + type, e); } }