Skip to content

Commit a90aef7

Browse files
committed
Added default values for properties
1 parent f8f784a commit a90aef7

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

bzst-dip-java-client/src/main/java/software/xdev/bzst/dip/client/model/configuration/BzstDipConfigurationBuilder.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.time.Duration;
2020
import java.time.LocalDate;
2121
import java.time.ZonedDateTime;
22+
import java.util.UUID;
2223
import java.util.function.Supplier;
2324

2425
import software.xdev.bzst.dip.client.exception.PropertyNotSetException;
@@ -443,15 +444,18 @@ public BzstDipConfiguration buildAndValidate()
443444
),
444445
this.getSetPropertyOrReadFromFileMessageType(
445446
this.messageType,
446-
PropertiesSupplier.PROPERTY_NAME_MESSAGE_TYPE
447+
PropertiesSupplier.PROPERTY_NAME_MESSAGE_TYPE,
448+
BzstCesopMessageTypeEnum.PMT
447449
),
448450
this.getSetPropertyOrReadFromFile(
449451
this.messageRefId,
450-
PropertiesSupplier.PROPERTY_NAME_MESSAGE_REF_ID
452+
PropertiesSupplier.PROPERTY_NAME_MESSAGE_REF_ID,
453+
UUID.randomUUID().toString()
451454
),
452455
this.getSetPropertyOrReadFromFile(
453456
this.reportingPeriodCesopYear,
454-
PropertiesSupplier.PROPERTY_NAME_REPORTING_PERIOD_CESOP_YEAR
457+
PropertiesSupplier.PROPERTY_NAME_REPORTING_PERIOD_CESOP_YEAR,
458+
String.valueOf(LocalDate.now().getYear())
455459
),
456460
this.getSetPropertyOrReadFromFileInteger(
457461
this.reportingPeriodCesopQuarter,
@@ -460,11 +464,13 @@ public BzstDipConfiguration buildAndValidate()
460464
),
461465
this.getSetPropertyOrReadFromFileTimestamp(
462466
this.timestamp,
463-
PropertiesSupplier.PROPERTY_NAME_TIMESTAMP
467+
PropertiesSupplier.PROPERTY_NAME_TIMESTAMP,
468+
ZonedDateTime.now()
464469
),
465470
this.getSetPropertyOrReadFromFileMessageTypeIndicCesop(
466471
this.messageTypeIndicCesop,
467-
PropertiesSupplier.PROPERTY_NAME_MESSAGE_TYPE_INDIC_CESOP
472+
PropertiesSupplier.PROPERTY_NAME_MESSAGE_TYPE_INDIC_CESOP,
473+
BzstCesopMessageTypeIndicEnum.CESOP_100
468474
),
469475
this.getSetPropertyOrReadFromFile(
470476
this.applicationCode.value,
@@ -720,13 +726,17 @@ private String getSetPropertyOrReadFromFile(
720726

721727
private ZonedDateTime getSetPropertyOrReadFromFileTimestamp(
722728
final ZonedDateTime builderProperty,
723-
final String propertyNameInFile)
729+
final String propertyNameInFile,
730+
final ZonedDateTime defaultProperty)
724731
{
725732
if(builderProperty != null)
726733
{
727734
return builderProperty;
728735
}
729-
return ZonedDateTime.parse(this.getSetPropertyOrReadFromFile(null, propertyNameInFile));
736+
return ZonedDateTime.parse(this.getSetPropertyOrReadFromFile(
737+
null,
738+
propertyNameInFile,
739+
defaultProperty.toString()));
730740
}
731741

732742
private BzstDipCountryCode getSetPropertyOrReadFromFileTransmittingCountry(
@@ -746,27 +756,31 @@ private BzstDipCountryCode getSetPropertyOrReadFromFileTransmittingCountry(
746756

747757
private BzstCesopMessageTypeEnum getSetPropertyOrReadFromFileMessageType(
748758
final BzstCesopMessageTypeEnum builderProperty,
749-
final String propertyNameInFile)
759+
final String propertyNameInFile,
760+
final BzstCesopMessageTypeEnum defaultProperty)
750761
{
751762
if(builderProperty != null)
752763
{
753764
return builderProperty;
754765
}
755766
return BzstCesopMessageTypeEnum.valueOf(this.getSetPropertyOrReadFromFile(
756767
null,
757-
propertyNameInFile));
768+
propertyNameInFile,
769+
defaultProperty.toString()));
758770
}
759771

760772
private BzstCesopMessageTypeIndicEnum getSetPropertyOrReadFromFileMessageTypeIndicCesop(
761773
final BzstCesopMessageTypeIndicEnum builderProperty,
762-
final String propertyNameInFile)
774+
final String propertyNameInFile,
775+
final BzstCesopMessageTypeIndicEnum defaultProperty)
763776
{
764777
if(builderProperty != null)
765778
{
766779
return builderProperty;
767780
}
768781
return BzstCesopMessageTypeIndicEnum.valueOf(this.getSetPropertyOrReadFromFile(
769782
null,
770-
propertyNameInFile));
783+
propertyNameInFile,
784+
defaultProperty.toString()));
771785
}
772786
}

0 commit comments

Comments
 (0)