@Test public void givenProfileNameWithNulls_thenIExpectExactlyEmpty() { ProfileName profileName = ProfileName.fromParts(null, null); assertSame(ProfileName.EMPTY, profileName); }
public static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName) { givenName = givenName == null ? "" : givenName; familyName = familyName == null ? "" : familyName; givenName = StringUtil.trimToFit(givenName.trim(), ProfileName.MAX_PART_LENGTH); familyName = StringUtil.trimToFit(familyName.trim(), ProfileName.MAX_PART_LENGTH); if (givenName.isEmpty() && familyName.isEmpty()) { return EMPTY; } return new ProfileName(givenName, familyName); }
ProfileName implements Parcelable { public static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName) { givenName = givenName == null ? "" : givenName; familyName = familyName == null ? "" : familyName; givenName = StringUtil.trimToFit(givenName.trim(), ProfileName.MAX_PART_LENGTH); familyName = StringUtil.trimToFit(familyName.trim(), ProfileName.MAX_PART_LENGTH); if (givenName.isEmpty() && familyName.isEmpty()) { return EMPTY; } return new ProfileName(givenName, familyName); } }
ProfileName implements Parcelable { public static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName) { givenName = givenName == null ? "" : givenName; familyName = familyName == null ? "" : familyName; givenName = StringUtil.trimToFit(givenName.trim(), ProfileName.MAX_PART_LENGTH); familyName = StringUtil.trimToFit(familyName.trim(), ProfileName.MAX_PART_LENGTH); if (givenName.isEmpty() && familyName.isEmpty()) { return EMPTY; } return new ProfileName(givenName, familyName); } private  ProfileName(@Nullable String givenName, @Nullable String familyName); private  ProfileName(Parcel in); }
ProfileName implements Parcelable { public static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName) { givenName = givenName == null ? "" : givenName; familyName = familyName == null ? "" : familyName; givenName = StringUtil.trimToFit(givenName.trim(), ProfileName.MAX_PART_LENGTH); familyName = StringUtil.trimToFit(familyName.trim(), ProfileName.MAX_PART_LENGTH); if (givenName.isEmpty() && familyName.isEmpty()) { return EMPTY; } return new ProfileName(givenName, familyName); } private  ProfileName(@Nullable String givenName, @Nullable String familyName); private  ProfileName(Parcel in); @NonNull String getGivenName(); @NonNull String getFamilyName(); boolean isEmpty(); boolean isGivenNameEmpty(); @NonNull String serialize(); @Override @NonNull String toString(); static @NonNull ProfileName fromSerialized(@Nullable String profileName); static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Override boolean equals(Object o); @Override int hashCode(); }
ProfileName implements Parcelable { public static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName) { givenName = givenName == null ? "" : givenName; familyName = familyName == null ? "" : familyName; givenName = StringUtil.trimToFit(givenName.trim(), ProfileName.MAX_PART_LENGTH); familyName = StringUtil.trimToFit(familyName.trim(), ProfileName.MAX_PART_LENGTH); if (givenName.isEmpty() && familyName.isEmpty()) { return EMPTY; } return new ProfileName(givenName, familyName); } private  ProfileName(@Nullable String givenName, @Nullable String familyName); private  ProfileName(Parcel in); @NonNull String getGivenName(); @NonNull String getFamilyName(); boolean isEmpty(); boolean isGivenNameEmpty(); @NonNull String serialize(); @Override @NonNull String toString(); static @NonNull ProfileName fromSerialized(@Nullable String profileName); static @NonNull ProfileName fromParts(@Nullable String givenName, @Nullable String familyName); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Override boolean equals(Object o); @Override int hashCode(); static final ProfileName EMPTY; static final int MAX_PART_LENGTH; static final Creator<ProfileName> CREATOR; }