@Test public void testLoadNotExists() { ClasspathConfigSource configSource = (ClasspathConfigSource) ConfigSources.classpath("application.unknown") .build(); assertThat(configSource.load(), is(Optional.empty())); }
@Override public Optional<Content> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } Content.Builder builder = Content.builder() .data(inputStream); mediaType.get().ifPresent(builder::mediaType); return Optional.of(builder.build()); }
ClasspathConfigSource extends AbstractConfigSource implements ConfigSource,
                                                                           ParsableSource { @Override public Optional<Content> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } Content.Builder builder = Content.builder() .data(inputStream); mediaType.get().ifPresent(builder::mediaType); return Optional.of(builder.build()); } }
ClasspathConfigSource extends AbstractConfigSource implements ConfigSource,
                                                                           ParsableSource { @Override public Optional<Content> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } Content.Builder builder = Content.builder() .data(inputStream); mediaType.get().ifPresent(builder::mediaType); return Optional.of(builder.build()); } ClasspathConfigSource(Builder builder); }
ClasspathConfigSource extends AbstractConfigSource implements ConfigSource,
                                                                           ParsableSource { @Override public Optional<Content> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } Content.Builder builder = Content.builder() .data(inputStream); mediaType.get().ifPresent(builder::mediaType); return Optional.of(builder.build()); } ClasspathConfigSource(Builder builder); static ClasspathConfigSource create(Config metaConfig); static ClasspathConfigSource create(String resource); static Collection<? super ClasspathConfigSource> createAll(String resource); static List<ConfigSource> createAll(Config metaConfig); static Builder builder(); @Override Optional<Content> load(); @Override String toString(); @Override Optional<String> mediaType(); @Override Optional<ConfigParser> parser(); }
ClasspathConfigSource extends AbstractConfigSource implements ConfigSource,
                                                                           ParsableSource { @Override public Optional<Content> load() throws ConfigException { if (null == resourceUrl) { return Optional.empty(); } InputStream inputStream; try { inputStream = resourceUrl.openStream(); } catch (IOException e) { throw new ConfigException("Failed to read configuration from classpath, resource: " + resource, e); } Content.Builder builder = Content.builder() .data(inputStream); mediaType.get().ifPresent(builder::mediaType); return Optional.of(builder.build()); } ClasspathConfigSource(Builder builder); static ClasspathConfigSource create(Config metaConfig); static ClasspathConfigSource create(String resource); static Collection<? super ClasspathConfigSource> createAll(String resource); static List<ConfigSource> createAll(Config metaConfig); static Builder builder(); @Override Optional<Content> load(); @Override String toString(); @Override Optional<String> mediaType(); @Override Optional<ConfigParser> parser();  }