@Test public void shouldLoadConstants() throws Exception { final String config = "MAX_COMMITTEES_PER_SLOT: 68\n" + "# 2**7 (= 128)\n" + "TARGET_COMMITTEE_SIZE: 129"; ConstantsReader.loadConstantsFrom( new ByteArrayInputStream(config.getBytes(StandardCharsets.UTF_8))); assertThat(Constants.MAX_COMMITTEES_PER_SLOT).isEqualTo(68); assertThat(Constants.TARGET_COMMITTEE_SIZE).isEqualTo(129); }
@SuppressWarnings("unchecked") public static void loadConstantsFrom(final InputStream source) throws IOException { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final Map<String, Object> values = (Map<String, Object>) mapper .readerFor( mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)) .readValues(source) .next(); values.forEach(ConstantsReader::setField); }
ConstantsReader { @SuppressWarnings("unchecked") public static void loadConstantsFrom(final InputStream source) throws IOException { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final Map<String, Object> values = (Map<String, Object>) mapper .readerFor( mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)) .readValues(source) .next(); values.forEach(ConstantsReader::setField); } }
ConstantsReader { @SuppressWarnings("unchecked") public static void loadConstantsFrom(final InputStream source) throws IOException { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final Map<String, Object> values = (Map<String, Object>) mapper .readerFor( mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)) .readValues(source) .next(); values.forEach(ConstantsReader::setField); }  }
ConstantsReader { @SuppressWarnings("unchecked") public static void loadConstantsFrom(final InputStream source) throws IOException { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final Map<String, Object> values = (Map<String, Object>) mapper .readerFor( mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)) .readValues(source) .next(); values.forEach(ConstantsReader::setField); }  @SuppressWarnings("unchecked") static void loadConstantsFrom(final InputStream source); }
ConstantsReader { @SuppressWarnings("unchecked") public static void loadConstantsFrom(final InputStream source) throws IOException { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final Map<String, Object> values = (Map<String, Object>) mapper .readerFor( mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)) .readValues(source) .next(); values.forEach(ConstantsReader::setField); }  @SuppressWarnings("unchecked") static void loadConstantsFrom(final InputStream source);  }