mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 959777 - Factor out PanelConfig validation to be used in all constructors (r=margaret)
This commit is contained in:
parent
5ed7090ad1
commit
a63ede5f73
@ -121,6 +121,8 @@ final class HomeConfig {
|
||||
mTitle = in.readString();
|
||||
mId = in.readString();
|
||||
mFlags = (EnumSet<Flags>) in.readSerializable();
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
public PanelConfig(PanelType type, String title, String id) {
|
||||
@ -128,25 +130,30 @@ final class HomeConfig {
|
||||
}
|
||||
|
||||
public PanelConfig(PanelType type, String title, String id, EnumSet<Flags> flags) {
|
||||
if (type == null) {
|
||||
mType = type;
|
||||
mTitle = title;
|
||||
mId = id;
|
||||
mFlags = flags;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
if (mType == null) {
|
||||
throw new IllegalArgumentException("Can't create PanelConfig with null type");
|
||||
}
|
||||
mType = type;
|
||||
|
||||
if (title == null) {
|
||||
throw new IllegalArgumentException("Can't create PanelConfig with null title");
|
||||
if (TextUtils.isEmpty(mTitle)) {
|
||||
throw new IllegalArgumentException("Can't create PanelConfig with empty title");
|
||||
}
|
||||
mTitle = title;
|
||||
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("Can't create PanelConfig with null id");
|
||||
if (TextUtils.isEmpty(mId)) {
|
||||
throw new IllegalArgumentException("Can't create PanelConfig with empty id");
|
||||
}
|
||||
mId = id;
|
||||
|
||||
if (flags == null) {
|
||||
if (mFlags == null) {
|
||||
throw new IllegalArgumentException("Can't create PanelConfig with null flags");
|
||||
}
|
||||
mFlags = flags;
|
||||
}
|
||||
|
||||
public PanelType getType() {
|
||||
|
Loading…
Reference in New Issue
Block a user