Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for multiple file configuration sources #154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,77 @@ public interface ConfigurationSource {

Optional<String> get(String key);

Optional<Boolean> getBoolean(String key);
default Optional<Boolean> getBoolean(String key) {

Optional<Integer> getInteger(String key);
Optional<String> value = get(key);

Optional<Long> getLong(String key);
return value.map(Boolean::valueOf);
}

default Optional<Integer> getInteger(String key) {

Optional<String> value = get(key);

if (value.isPresent()) {

try {
return Optional.of(Integer.valueOf(value.get()));
} catch (NumberFormatException e) {
return Optional.empty();
}
} else {
return Optional.empty();
}
}

default Optional<Long> getLong(String key) {

Optional<String> value = get(key);

if (value.isPresent()) {

try {
return Optional.of(Long.valueOf(value.get()));
} catch (NumberFormatException e) {
return Optional.empty();
}
} else {
return Optional.empty();
}
}

default Optional<Double> getDouble(String key) {

Optional<String> value = get(key);

if (value.isPresent()) {

try {
return Optional.of(Double.valueOf(value.get()));
} catch (NumberFormatException e) {
return Optional.empty();
}
} else {
return Optional.empty();
}
}

default Optional<Float> getFloat(String key) {

Optional<String> value = get(key);

Optional<Double> getDouble(String key);
if (value.isPresent()) {

Optional<Float> getFloat(String key);
try {
return Optional.of(Float.valueOf(value.get()));
} catch (NumberFormatException e) {
return Optional.empty();
}

} else {
return Optional.empty();
}
}

Optional<Integer> getListSize(String key);

Expand Down
Loading