Require OS version to be non-empty
@@ -16,7 +16,7 @@ public class OsVersion {
private final boolean active;
public OsVersion(Version version, boolean active) {
- this.version = version;
+ this.version = requireNonEmpty(version);
this.active = active;
}
@@ -49,4 +49,10 @@ public class OsVersion {
return "OS version " + version + " [active: " + active + "]";
}
+ private static Version requireNonEmpty(Version version) {
+ Objects.requireNonNull(version, "version must be non-null");
+ if (version.isEmpty()) throw new IllegalArgumentException("version must be non-empty");
+ return version;
+ }
+
}
