LicenseNameWithTextUtils { public static LicenseNameWithText sanitize(LicenseNameWithText licenseNameWithText) { if (licenseNameWithText.isSetLicenseName()) { String name = licenseNameWithText.getLicenseName().trim(); licenseNameWithText.setLicenseName(name.isEmpty() ? null : name); } if (licenseNameWithText.isSetLicenseText()) { String text = licenseNameWithText.getLicenseText().trim(); licenseNameWithText.setLicenseText(text.isEmpty() ? null : text); } if (licenseNameWithText.isSetAcknowledgements()) { String acknowledgments = licenseNameWithText.getAcknowledgements().trim(); licenseNameWithText.setAcknowledgements(acknowledgments.isEmpty() ? null : acknowledgments); } return licenseNameWithText; }  static LicenseNameWithText sanitize(LicenseNameWithText licenseNameWithText); static boolean isEmpty(LicenseNameWithText licenseNameWithText); static boolean licenseNameWithTextEquals(LicenseNameWithText lnwt1, LicenseNameWithText lnwt2);  }
@Test public void testSanitize() { LicenseNameWithText licenseNameWithText; licenseNameWithText = createLicense("name", null, null); LicenseNameWithTextUtils.sanitize(licenseNameWithText); Assert.assertThat(licenseNameWithText.getLicenseName(), Matchers.is("name")); licenseNameWithText = createLicense("\n", null, null); LicenseNameWithTextUtils.sanitize(licenseNameWithText); Assert.assertNull(licenseNameWithText.getLicenseName()); licenseNameWithText = createLicense(null, "text", null); LicenseNameWithTextUtils.sanitize(licenseNameWithText); Assert.assertThat(licenseNameWithText.getLicenseText(), Matchers.is("text")); licenseNameWithText = createLicense(null, " ", null); LicenseNameWithTextUtils.sanitize(licenseNameWithText); Assert.assertNull(licenseNameWithText.getLicenseText()); licenseNameWithText = createLicense(null, null, "acks"); LicenseNameWithTextUtils.sanitize(licenseNameWithText); Assert.assertThat(licenseNameWithText.getAcknowledgements(), Matchers.is("acks")); licenseNameWithText = createLicense(null, null, " "); LicenseNameWithTextUtils.sanitize(licenseNameWithText); Assert.assertNull(licenseNameWithText.getAcknowledgements()); }