diff --git a/CHANGELOG.md b/CHANGELOG.md index 49252a92..70037e0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Prowide Core - CHANGELOG #### 9.5.2 - SNAPSHOT - * Added new SRU2023FieldEnum with all the available field names + * Added new FieldEnum with all the available field names #### 9.5.1 - June 2024 * (PW-1913) Added IBAN validation for Egypt local account structure diff --git a/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java b/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java index 68a1116e..5b865555 100644 --- a/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java +++ b/src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java @@ -725,13 +725,34 @@ public enum FieldEnum { F619, F999; - public String getFieldName() { + /** + * Retrieves the field name associated with the enum constant. + * The field name is the part of the enum constant name after the initial 'F'. + * + * @return the field name as a {@code String} + *
+ * Example: + * FieldEnum field = FieldEnum.F11A; + * String fieldName = field.fieldName(); // returns "11A" + */ + public String fieldName() { return name().substring(1); // Skips the first character 'F' and returns the rest of the name } - public static FieldEnum fromCode(String code) { + /** + * Converts a string field name into its corresponding {@code FieldEnum} constant. + * The input should be the string representation of the field without the initial 'F'. + * + * @param fieldName the string field name (e.g., "11A", "12B") + * @return the corresponding {@code FieldEnum} constant, or {@code null} if not found + *
+ * Example: + * FieldEnum field = FieldEnum.fromFieldName("11A"); // returns FieldEnum.F11A + * FieldEnum unknownField = FieldEnum.fromFieldName("99Z"); // returns null + */ + public static FieldEnum fromFieldName(String fieldName) { for (FieldEnum field : FieldEnum.values()) { - if (field.getFieldName().equals(code)) { + if (field.fieldName().equals(fieldName)) { return field; } } diff --git a/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java b/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java index cc1b17bb..389a7384 100644 --- a/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java +++ b/src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java @@ -7,42 +7,42 @@ class FieldEnumTest { @Test - void testGetFieldName() { - // Validate that getFieldName returns the correct value - assertEquals("11A", FieldEnum.F11A.getFieldName()); - assertEquals("14P", FieldEnum.F14P.getFieldName()); - assertEquals("30K", FieldEnum.F30K.getFieldName()); + void testfieldName() { + // Validate that fieldName returns the correct value + assertEquals("11A", FieldEnum.F11A.fieldName()); + assertEquals("14P", FieldEnum.F14P.fieldName()); + assertEquals("30K", FieldEnum.F30K.fieldName()); } @Test - void testFromCodeValid() { - // Validate that fromCode returns the correct enum when a valid code is provided - assertEquals(FieldEnum.F11A, FieldEnum.fromCode("11A")); - assertEquals(FieldEnum.F14R, FieldEnum.fromCode("14R")); - assertEquals(FieldEnum.F30K, FieldEnum.fromCode("30K")); + void testfromFieldNameValid() { + // Validate that fromFieldName returns the correct enum when a valid code is provided + assertEquals(FieldEnum.F11A, FieldEnum.fromFieldName("11A")); + assertEquals(FieldEnum.F14R, FieldEnum.fromFieldName("14R")); + assertEquals(FieldEnum.F30K, FieldEnum.fromFieldName("30K")); } @Test - void testFromCodeInvalid() { - // Validate that fromCode returns null when an invalid code is provided - assertNull(FieldEnum.fromCode("930K")); - assertNull(FieldEnum.fromCode("ABC")); - assertNull(FieldEnum.fromCode("")); + void testfromFieldNameInvalid() { + // Validate that fromFieldName returns null when an invalid code is provided + assertNull(FieldEnum.fromFieldName("930K")); + assertNull(FieldEnum.fromFieldName("ABC")); + assertNull(FieldEnum.fromFieldName("")); } @Test - void testFromCodeEdgeCases() { + void testfromFieldNameEdgeCases() { // Validate edge cases, such as lowercase inputs, to ensure the method is case-sensitive - assertNull(FieldEnum.fromCode("11a")); // should return null because "11a" is lowercase - assertNull(FieldEnum.fromCode(" 11A")); // should return null because of the leading space - assertNull(FieldEnum.fromCode("11A ")); // should return null because of the trailing space + assertNull(FieldEnum.fromFieldName("11a")); // should return null because "11a" is lowercase + assertNull(FieldEnum.fromFieldName(" 11A")); // should return null because of the leading space + assertNull(FieldEnum.fromFieldName("11A ")); // should return null because of the trailing space } @Test void testAllEnumValues() { // Validate that all enum values have the correct field name for (FieldEnum field : FieldEnum.values()) { - assertEquals(field.name().substring(1), field.getFieldName()); + assertEquals(field.name().substring(1), field.fieldName()); } } }