Merge "Update the Builder to add the title parameter checking"

This commit is contained in:
TreeHugger Robot
2019-08-12 00:42:14 +00:00
committed by Android (Google) Code Review

View File

@@ -99,7 +99,7 @@ public class FooterPreference extends Preference {
* To set the key value of the {@link FooterPreference}.
* @param key The key value.
*/
public Builder setKey(String key) {
public Builder setKey(@NonNull String key) {
mKey = key;
return this;
}
@@ -128,12 +128,13 @@ public class FooterPreference extends Preference {
public FooterPreference build() {
final FooterPreference footerPreference = new FooterPreference(mContext);
footerPreference.setSelectable(false);
if (TextUtils.isEmpty(mTitle)) {
throw new IllegalArgumentException("Footer title cannot be empty!");
}
footerPreference.setTitle(mTitle);
if (!TextUtils.isEmpty(mKey)) {
footerPreference.setKey(mKey);
}
if (!TextUtils.isEmpty(mTitle)) {
footerPreference.setTitle(mTitle);
}
return footerPreference;
}
}