Skip to content

Commit

Permalink
Mark unstructured address as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed Jun 1, 2024
1 parent 0256702 commit b8f2b1a
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ private static void addDpiMetadata(IIOMetadata metadata, int dpi) throws IIOInva
root.appendChild(physNode);
metadata.mergeTree(metadata.getNativeMetadataFormatName(), root);

IIOMetadataNode dimension = createDimensionNode(dpi);

root = new IIOMetadataNode(PNG_STANDARD_METADATA_FORMAT);
root.appendChild(dimension);
metadata.mergeTree(PNG_STANDARD_METADATA_FORMAT, root);
}

private static IIOMetadataNode createDimensionNode(int dpi) {
// standard metadata format
double pixelsPerMM = dpi / 25.4;
String pixelsPerMMString = Double.toString(pixelsPerMM);
Expand All @@ -188,10 +196,7 @@ private static void addDpiMetadata(IIOMetadata metadata, int dpi) throws IIOInva
IIOMetadataNode dimension = new IIOMetadataNode("Dimension");
dimension.appendChild(horizontalPixelSize);
dimension.appendChild(verticalPixelSize);

root = new IIOMetadataNode(PNG_STANDARD_METADATA_FORMAT);
root.appendChild(dimension);
metadata.mergeTree(PNG_STANDARD_METADATA_FORMAT, root);
return dimension;
}

private static void addTextMetadata(IIOMetadata metadata) throws IIOInvalidTreeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ public void setName(String name) {
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @deprecated Use a structured address instead. Will be removed in release 4.
*
* @return address line 1
*/
@Deprecated
@SuppressWarnings({"DeprecatedIsStillUsed", "java:S1133"})
public String getAddressLine1() {
return addressLine1;
}
Expand All @@ -164,8 +168,12 @@ public String getAddressLine1() {
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @deprecated Use a structured address instead. Will be removed in release 4.
*
* @param addressLine1 address line 1
*/
@Deprecated
@SuppressWarnings({"DeprecatedIsStillUsed", "java:S1133"})
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
changeType(Type.COMBINED_ELEMENTS);
Expand All @@ -181,8 +189,12 @@ public void setAddressLine1(String addressLine1) {
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @deprecated Use a structured address instead. Will be removed in release 4.
*
* @return address line 2
*/
@Deprecated
@SuppressWarnings({"DeprecatedIsStillUsed", "java:S1133"})
public String getAddressLine2() {
return addressLine2;
}
Expand All @@ -201,8 +213,12 @@ public String getAddressLine2() {
* Starting November 25, 2025, banks will no longer accept payments using combined address elements.
* </p>
*
* @deprecated Use a structured address instead. Will be removed in release 4.
*
* @param addressLine2 address line 2
*/
@Deprecated
@SuppressWarnings({"DeprecatedIsStillUsed", "java:S1133"})
public void setAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
changeType(Type.COMBINED_ELEMENTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private static String formatAmountForDisplay(BigDecimal amount) {
return createAmountFormatter().format(amount);
}

@SuppressWarnings("deprecation")
private static String formatAddressForDisplay(Address address, boolean withCountryCode) {
StringBuilder sb = new StringBuilder();
sb.append(address.getName());
Expand Down Expand Up @@ -228,6 +229,7 @@ private static boolean isForeignAddress(Address address, BillFormat format) {
return address != null && !format.getLocalCountryCode().equals(address.getCountryCode());
}

@SuppressWarnings("deprecation")
private Address createReducedAddress(Address address) {
// Address without street / house number
Address reducedAddress = new Address();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private String createText() {
return textBuilder.toString();
}

@SuppressWarnings("deprecation")
private void appendPerson(Address address) {
if (address != null) {
appendDataField(address.getType() == Address.Type.STRUCTURED ? "S" : "K"); // AdrTp
Expand Down Expand Up @@ -217,6 +218,7 @@ private static void decodeAlternativeSchemes(String[] lines, Bill bill) {
* @param isOptional indicates if address is optional
* @return decoded address or {@code null} if address is optional and empty
*/
@SuppressWarnings("deprecation")
private static Address decodeAddress(String[] lines, int startLine, boolean isOptional) {

boolean isEmpty = lines[startLine].isEmpty() && lines[startLine + 1].isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private SwicoBillInformation decodeIt(String billInfoText) {
}

private void decodeElement(SwicoBillInformation billInformation, int tag, String value) {
if (value.length() == 0)
if (value.isEmpty())
return;

switch (tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ private void validateEmptyAddress(String fieldRoot, boolean mandatory) {
}
}

@SuppressWarnings("deprecation")
private void emitErrorsForConflictingType(Address addressOut, String fieldRoot) {
if (addressOut.getAddressLine1() != null)
validationResult.addMessage(Type.ERROR, fieldRoot + ValidationConstants.SUBFIELD_ADDRESS_LINE_1, ValidationConstants.KEY_ADDRESS_TYPE_CONFLICT);
Expand All @@ -291,6 +292,7 @@ private void emitErrorsForConflictingType(Address addressOut, String fieldRoot)
validationResult.addMessage(Type.ERROR, fieldRoot + ValidationConstants.SUBFIELD_TOWN, ValidationConstants.KEY_ADDRESS_TYPE_CONFLICT);
}

@SuppressWarnings("deprecation")
private void checkMandatoryAddressFields(Address addressOut, String fieldRoot) {
validateMandatory(addressOut.getName(), fieldRoot, ValidationConstants.SUBFIELD_NAME);
if (addressOut.getType() == Address.Type.STRUCTURED || addressOut.getType() == Address.Type.UNDETERMINED) {
Expand All @@ -303,6 +305,7 @@ private void checkMandatoryAddressFields(Address addressOut, String fieldRoot) {
validateMandatory(addressOut.getCountryCode(), fieldRoot, ValidationConstants.SUBFIELD_COUNTRY_CODE);
}

@SuppressWarnings("deprecation")
private void cleanAddressFields(Address addressOut, String fieldRoot) {
addressOut.setName(clippedValue(addressOut.getName(), 70, fieldRoot, ValidationConstants.SUBFIELD_NAME));
if (addressOut.getType() == Address.Type.STRUCTURED) {
Expand All @@ -327,6 +330,7 @@ private boolean validateIBAN(String iban) {
return true;
}

@SuppressWarnings("deprecation")
private Address cleanedPerson(Address addressIn, String fieldRoot) {
if (addressIn == null)
return null;
Expand Down Expand Up @@ -383,6 +387,7 @@ private boolean validateLength(String value, int maxLength, String field) {
}
}

@SuppressWarnings("SameParameterValue")
private String clippedValue(String value, int maxLength, String field) {
if (value != null && value.length() > maxLength) {
validationResult.addMessage(Type.WARNING, field, ValidationConstants.KEY_FIELD_VALUE_CLIPPED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void setName() {
}

@Test
@SuppressWarnings("deprecation")
void setAddressLine1() {
Address address = new Address();
address.setAddressLine1("TYUI");
Expand All @@ -40,6 +41,7 @@ void setAddressLine1() {
}

@Test
@SuppressWarnings("deprecation")
void setAddressLine2() {
Address address = new Address();
address.setAddressLine2("vbnm");
Expand Down Expand Up @@ -87,6 +89,7 @@ void setCountryCode() {
}

@Test
@SuppressWarnings("deprecation")
void conflictTest1() {
Address address = new Address();
address.setStreet("XY");
Expand All @@ -95,6 +98,7 @@ void conflictTest1() {
}

@Test
@SuppressWarnings("deprecation")
void conflictTest2() {
Address address = new Address();
address.setHouseNo("XY");
Expand All @@ -103,6 +107,7 @@ void conflictTest2() {
}

@Test
@SuppressWarnings("deprecation")
void conflictTest3() {
Address address = new Address();
address.setPostalCode("XY");
Expand All @@ -111,6 +116,7 @@ void conflictTest3() {
}

@Test
@SuppressWarnings("deprecation")
void conflictTest4() {
Address address = new Address();
address.setTown("XY");
Expand Down Expand Up @@ -147,6 +153,7 @@ void hashObjectCombined() {
}

@Test
@SuppressWarnings("deprecation")
void clearTestStructured() {
Address address1 = createStructuredAddress();
address1.clear();
Expand All @@ -162,6 +169,7 @@ void clearTestStructured() {
}

@Test
@SuppressWarnings("deprecation")
void clearTestCombined() {
Address address1 = createCombinedElementAddress();
address1.clear();
Expand All @@ -184,6 +192,7 @@ void toStringTest() {
}

@Test
@SuppressWarnings({"EqualsWithItself", "AssertBetweenInconvertibleTypes"})
void testEqualsTrivial() {
Address address = createCombinedElementAddress();
assertEquals(address, address);
Expand Down Expand Up @@ -213,6 +222,7 @@ private Address createStructuredAddress() {
return address;
}

@SuppressWarnings("deprecation")
private Address createCombinedElementAddress() {
Address address = new Address();
address.setName("Cornelia Singer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void toStringTest() {
assertEquals("AlternativeScheme{name='Paymit', instruction='PM,12341234,1241234'}", text);
}

@SuppressWarnings({"AssertBetweenInconvertibleTypes", "EqualsWithItself"})
@Test
void testEqualsTrivial() {
AlternativeScheme scheme = new AlternativeScheme("Paymit", "PM,12341234,1241234");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void toStringTest() {
assertEquals("BillFormat{outputSize=QR_BILL_ONLY, language=EN, separatorType=DASHED_LINE_WITH_SCISSORS, fontFamily='Helvetica,Arial,\"Liberation Sans\"', graphicsFormat=SVG, resolution=144, marginLeft=5.0, marginRight=5.0, localCountryCode='CH'}", text);
}

@SuppressWarnings({"EqualsWithItself", "AssertBetweenInconvertibleTypes"})
@Test
void testEqualsTrivial() {
BillFormat format = new BillFormat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void creditorWithInvalidCountryCode(String countryCode, String messageKey) {
}

@Test
@SuppressWarnings("deprecation")
void creditorWithConflictingAddress() {
bill = SampleData.getExample1();
bill.getCreditor().setAddressLine1("Conflict");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ static Bill getBillData3() {
"EPD"
};

@SuppressWarnings("deprecation")
static Bill getBillData4() {
Bill bill = new Bill();
bill.getFormat().setLanguage(Language.EN);
Expand Down Expand Up @@ -281,6 +282,7 @@ static Bill getBillData4() {
"EPD"
};

@SuppressWarnings("deprecation")
static Bill getBillData5() {
Bill bill = new Bill();
bill.getFormat().setLanguage(Language.EN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void dueDate_isNull() {
assertNull(billInformation.getDueDate());
}

@SuppressWarnings({"EqualsWithItself", "AssertBetweenInconvertibleTypes"})
@Test
void testEqualsTrivial() {
SwicoBillInformation info = new SwicoBillInformation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static Bill getExample4() {
return bill;
}

@SuppressWarnings("deprecation")
public static Bill getExample5() {
Bill bill = new Bill();
bill.getFormat().setLanguage(Language.RM);
Expand All @@ -139,6 +140,7 @@ public static Bill getExample5() {
return bill;
}

@SuppressWarnings("deprecation")
public static Bill getExample6() {
Bill bill = new Bill();
bill.getFormat().setLanguage(Language.EN);
Expand All @@ -156,6 +158,7 @@ public static Bill getExample6() {
return bill;
}

@SuppressWarnings("deprecation")
public static Bill getExample7() {
Bill bill = new Bill();
bill.getFormat().setLanguage(Language.DE);
Expand Down

0 comments on commit b8f2b1a

Please sign in to comment.