Skip to content

Commit

Permalink
GH-36 customizable datetime, time and date adapters in the marshaling…
Browse files Browse the repository at this point in the history
…/unmarshalling (#44)

* Added adapters for date time, time, and date in the model via annotations
* Added default adapters implementations with different options to customize
* Added default adapters for jaxb when no other is set
* Refactored the xml and message serialization methods with a DTO parameter
  • Loading branch information
zubri authored Mar 7, 2022
1 parent 1c93ab4 commit ba702f4
Show file tree
Hide file tree
Showing 4,794 changed files with 51,505 additions and 22,474 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Prowide ISO 20022 - CHANGELOG
-----------------------------------------------------------------------------------------------------------------------

9.2.6 SNAPSHOT
* (GH-36) Added customizable datetime, date and time adapter in the MxWriteConfiguration, MxReadConfiguration
* Changed the default date time serialization to local time with UTC offset format YYYY-MM-DDThh:mm:ss.sss+/-hh:mm
* Encapsulated the serialization options in a DTO, when calling xml or message methods in AbstractMX and AppHdr
* Validate.notNull -> Objects.requireNonNull

RELEASE 9.2.5 - January 2022
* (GH-37) Updated dependency: gson:2.8.8 -> gson:2.8.9

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'maven-publish'

def SRU = "2021"

version = "SRU${SRU}-9.2.5"
version = "SRU${SRU}-9.2.6-SNAPSHOT"
group 'com.prowidesoftware'

sourceCompatibility = '1.8'
Expand Down Expand Up @@ -191,7 +191,7 @@ javadoc {
// declared dependencies for pom generation
dependencies {
// included build (keep in sync with the latest Prowide Core version)
api 'com.prowidesoftware:pw-swift-core:SRU2021-9.2.10'
api 'com.prowidesoftware:pw-swift-core:SRU2021-9.2.11'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.code.gson:gson:2.8.9'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.prowidesoftware.swift.utils.Lib;
import com.prowidesoftware.swift.utils.SafeXmlUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
Expand All @@ -35,6 +34,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;

Expand Down Expand Up @@ -74,7 +74,7 @@ public class MxParser {
@Deprecated
@ProwideDeprecated(phase3 = TargetYear.SRU2022)
public MxParser(final File file) throws IOException {
Validate.notNull(file);
Objects.requireNonNull(file);
this.buffer = Lib.readFile(file);
DeprecationUtils.phase2(MxParser.class, "MxParser(File)", "The MxParser class is no longer useful or has been replaced by similar features in AbstractMX, AppHdr, AppHdrParser, MxNode or MxParseUtils");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MxId() {
* @throws IllegalArgumentException if namespace parameter cannot be parsed as MX identification
*/
public MxId(final String namespace) {
Validate.notNull(namespace);
Objects.requireNonNull(namespace);
final Matcher matcher = pattern.matcher(namespace);
if (matcher.matches()) {
final String bpStr = matcher.group(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.logging.Level;

/**
Expand Down Expand Up @@ -65,7 +62,7 @@ public MxNode(final MxNode parent, final String localName) {
* @since 9.1.2
*/
public static MxNode parse(final String xml) {
Validate.notNull(xml, "the XML to parser cannot be null");
Objects.requireNonNull(xml, "the XML to parser cannot be null");
Validate.notBlank(xml, "the XML to parser cannot be blank");
try {
XMLReader xmlReader = SafeXmlUtils.reader(true, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public MxSwiftMessage(final AbstractMX mx) {
public MxSwiftMessage(final AbstractMX mx, final MessageMetadataStrategy metadataStrategy) {
// instead of reusing the constructor from XML with mx.message() as parameter
// we set the message and run the update directly to avoid an unnecessary message type detection
Validate.notNull(mx, "the message model cannot be null");
Validate.notNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
Objects.requireNonNull(mx, "the message model cannot be null");
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
setMessage(mx.message());
_updateFromMessage(mx.getMxId(), metadataStrategy);
}
Expand Down Expand Up @@ -239,7 +239,7 @@ protected void updateFromMessage() {
*/
@Override
protected void updateFromMessage(final MessageMetadataStrategy metadataStrategy) {
Validate.notNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
_updateFromMessage(null, metadataStrategy);
}

Expand All @@ -262,8 +262,8 @@ public void updateFromModel(final AbstractMX mx) {
}

public void updateFromModel(final AbstractMX mx, final MessageMetadataStrategy metadataStrategy) {
Validate.notNull(mx, "the mx parameter cannot be null");
Validate.notNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
Objects.requireNonNull(mx, "the mx parameter cannot be null");
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
setMessage(mx.message());
setFileFormat(FileFormat.MX);
extractMetadata(mx.getMxId(), mx.getAppHdr(), metadataStrategy);
Expand Down Expand Up @@ -360,8 +360,8 @@ public void updateFromXML(final String xml, final MxId id) {
* @since 9.1.6
*/
public void updateFromXML(final String xml, final MxId id, final MessageMetadataStrategy metadataStrategy) {
Validate.notNull(xml, "the xml message parameter cannot be null");
Validate.notNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
Objects.requireNonNull(xml, "the xml message parameter cannot be null");
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null");
setMessage(xml);
setFileFormat(FileFormat.MX);
_updateFromMessage(id, metadataStrategy);
Expand Down Expand Up @@ -499,7 +499,7 @@ public String getCategory() {
* @since 9.1.6
*/
public void updateMetadata(MessageMetadataStrategy strategy) {
Validate.notNull(strategy, "the strategy for metadata extraction cannot be null");
Objects.requireNonNull(strategy, "the strategy for metadata extraction cannot be null");
applyStrategy(getMessage(), strategy);
}

Expand Down
Loading

0 comments on commit ba702f4

Please sign in to comment.