Skip to content

Commit

Permalink
Collapse the condition into the assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Nov 19, 2024
1 parent 8467326 commit 659ad01
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ private static Object innerDeepCopy(final Object value, final boolean unmodifiab
copy.add(innerDeepCopy(itemValue, unmodifiable));
}
return unmodifiable ? Collections.unmodifiableList(copy) : copy;
} else if (value == null || value instanceof String || value instanceof Number || value instanceof Boolean) {
return value;
} else {
// if the previous list of expected value types ends up not being exhaustive, then we want to learn about that
// if this list of expected value types ends up not being exhaustive, then we want to learn about that
// at development time, but it's probably better to err on the side of passing through the value at runtime
assert false : "unexpected value type [" + value.getClass() + "]";
assert (value == null || value instanceof String || value instanceof Number || value instanceof Boolean)
: "unexpected value type [" + value.getClass() + "]";
return value;
}
}
Expand Down

0 comments on commit 659ad01

Please sign in to comment.