Polish 'Simplify conditionals'

See gh-39259
This commit is contained in:
Phillip Webb
2024-01-23 08:54:52 -08:00
parent 65a1ff84e6
commit ddb769bf7f
7 changed files with 17 additions and 10 deletions

View File

@@ -55,8 +55,12 @@ public class ClassLoaderFile implements Serializable {
*/
public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) {
Assert.notNull(kind, "Kind must not be null");
Assert.isTrue((kind != Kind.DELETED) == (contents != null),
() -> "Contents must " + ((kind != Kind.DELETED) ? "not " : "") + "be null");
if (kind == Kind.DELETED) {
Assert.isTrue(contents == null, "Contents must be null");
}
else {
Assert.isTrue(contents != null, "Contents must not be null");
}
this.kind = kind;
this.lastModified = lastModified;
this.contents = contents;