Skip to content

Commit

Permalink
replace if else with ternary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Revedko committed Jan 19, 2017
1 parent 9da658f commit 6ae4122
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ public <T> T get(@NonNull String key, @NonNull Type clazz) {

@Override public long getLong(@NonNull String key, long defaultValue) {
Object o = map.get(key);
if (o != null) {
return ((Long) o);
} else {
return defaultValue;
}
return o != null ? (long) o : defaultValue;
}

@Override public void putInt(@NonNull String key, int number) {
Expand All @@ -40,11 +36,7 @@ public <T> T get(@NonNull String key, @NonNull Type clazz) {

@Override public int getInt(@NonNull String key, int defaultValue) {
Object o = map.get(key);
if (o != null) {
return ((Integer) o);
} else {
return defaultValue;
}
return o != null ? (int) o : defaultValue;
}

@Override public void putBoolean(@NonNull String key, boolean value) {
Expand All @@ -53,11 +45,7 @@ public <T> T get(@NonNull String key, @NonNull Type clazz) {

@Override public boolean getBoolean(@NonNull String key, boolean defaultValue) {
Object o = map.get(key);
if (o != null) {
return ((Boolean) o);
} else {
return defaultValue;
}
return o != null ? (boolean) o : defaultValue;
}

@Override public void putString(@NonNull String key, @NonNull String str) {
Expand Down

0 comments on commit 6ae4122

Please sign in to comment.