Skip to content

Commit

Permalink
Merge pull request #264 from barspi/master
Browse files Browse the repository at this point in the history
OriginalDataElementsWrapper: change STAN to a long to support 12-digi…
  • Loading branch information
ar authored Oct 6, 2022
2 parents 9ea9283 + 254fb86 commit a468489
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ public final class OriginalDataElementsWrapper {
private static final int MAX_FIELD_LENGTH = 41;

private String originalMTI;
private int originalSTAN;
private long originalSTAN;
private Date originalLocalDate;
private String originalAcquiringInstCode;

public OriginalDataElementsWrapper() { }

public OriginalDataElementsWrapper(String fieldValue) {

Objects.requireNonNull(fieldValue);

if (fieldValue.length() > MAX_FIELD_LENGTH)
Expand All @@ -50,11 +49,9 @@ public OriginalDataElementsWrapper(String fieldValue) {
}

private void parse(String fieldValue) {

try {

setOriginalMTI(fieldValue.substring(0, 4));
setOriginalSTAN(Integer.valueOf(fieldValue.substring(4, 16)));
setOriginalSTAN(Long.parseLong(fieldValue.substring(4, 16)));
setOriginalLocalDate(DateUtils.parseDate(fieldValue.substring(16, 30), "yyyyMMddHHmmss"));
setOriginalAcquiringInstCode(fieldValue.substring(30));
}
Expand All @@ -65,15 +62,14 @@ private void parse(String fieldValue) {
}

public String serialize() {

StringBuilder r = new StringBuilder();

if (StringUtils.isNotBlank(getOriginalMTI()))
r.append(StringUtils.leftPad(getOriginalMTI(), 4, '0'));
else
r.append("0000");

r.append(StringUtils.leftPad(Integer.toString(getOriginalSTAN()), 12, '0'));
r.append(StringUtils.leftPad(Long.toString(getOriginalSTAN()), 12, '0'));

if (getOriginalLocalDate() != null)
r.append(ISODate.formatDate(getOriginalLocalDate(), "yyyyMMddHHmmss"));
Expand Down Expand Up @@ -101,12 +97,11 @@ public void setOriginalMTI(String originalMTI) {
this.originalMTI = originalMTI;
}

public int getOriginalSTAN() {
public long getOriginalSTAN() {
return originalSTAN;
}

public void setOriginalSTAN(int originalSTAN) {

public void setOriginalSTAN(long originalSTAN) {
if (originalSTAN < 0)
throw new IllegalArgumentException("originalSTAN must be a positive number");

Expand All @@ -126,7 +121,6 @@ public String getOriginalAcquiringInstCode() {
}

public void setOriginalAcquiringInstCode(String originalAcquiringInstCode) {

Objects.requireNonNull(originalAcquiringInstCode);

if (originalAcquiringInstCode.length() > 11)
Expand Down

0 comments on commit a468489

Please sign in to comment.