Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. /*
  2. * ************************************************************************
  3. * Copyright (C) Wolters Kluwer Financial Services. All rights reserved.
  4. *
  5. * This computer program is protected by copyright law and international
  6. * treaties. Unauthorized reproduction or distribution of this program,
  7. * or any portion of it, may result in severe civil and criminal penalties,
  8. * and will be prosecuted to the maximum extent possible under the law.
  9. * ************************************************************************
  10. */
  11.  
  12. package com.wolterskluwer.reg.reporting.datasets.model;
  13.  
  14. import java.time.LocalDate;
  15. import java.util.Objects;
  16.  
  17. public class DataSetBO {
  18.  
  19. private final Long id;
  20. private final String dataSetName;
  21. private final DataSetType dataSetType;
  22. private final Long dataLot;
  23. private final LocalDate referenceDate;
  24. private final Long inputDataReference;
  25. private final int assignedSubmissions;
  26. private final int allocatedSubmissions;
  27.  
  28.  
  29. private DataSetBO(final DataSetBOBuilder dataSetBOBuilder) {
  30. this.id = dataSetBOBuilder.id;
  31. this.dataSetName = dataSetBOBuilder.dataSetName;
  32. this.dataSetType = dataSetBOBuilder.dataSetType;
  33. this.dataLot = dataSetBOBuilder.dataLot;
  34. this.referenceDate = dataSetBOBuilder.referenceDate;
  35. this.inputDataReference = dataSetBOBuilder.inputDataReference;
  36. this.assignedSubmissions = dataSetBOBuilder.assignedSubmissions;
  37. this.allocatedSubmissions = dataSetBOBuilder.allocatedSubmissions;
  38. }
  39.  
  40. public Long getId() {
  41. return this.id;
  42. }
  43.  
  44. public String getDataSetName() {
  45. return this.dataSetName;
  46. }
  47.  
  48. public DataSetType getDataSetType() {
  49. return this.dataSetType;
  50. }
  51.  
  52. public Long getDataLot() {
  53. return this.dataLot;
  54. }
  55.  
  56. public LocalDate getReferenceDate() {
  57. return this.referenceDate;
  58. }
  59.  
  60. public Long getInputDataReference() {
  61. return this.inputDataReference;
  62. }
  63.  
  64. public int getAssignedSubmissions() {
  65. return this.assignedSubmissions;
  66. }
  67.  
  68. public int getAllocatedSubmissions() {
  69. return this.allocatedSubmissions;
  70. }
  71.  
  72. public DataSetBOBuilder toBuilder() {
  73. return new DataSetBOBuilder().withId(this.id)
  74. .withDataSetName(this.dataSetName)
  75. .withDataSetType(this.dataSetType)
  76. .withDataLot(this.dataLot)
  77. .withReferenceDate(this.referenceDate)
  78. .withInputDataReference(this.inputDataReference)
  79. .withAssignedSubmissions(this.assignedSubmissions)
  80. .withAllocatedSubmissions(this.allocatedSubmissions);
  81. }
  82.  
  83. public static final class DataSetBOBuilder {
  84. private String dataSetName;
  85. private Long id;
  86. private DataSetType dataSetType;
  87. private Long dataLot;
  88. private LocalDate referenceDate;
  89. private Long inputDataReference;
  90. private int assignedSubmissions;
  91. private int allocatedSubmissions;
  92.  
  93. public DataSetBOBuilder withDataSetName(final String dataSetName) {
  94. this.dataSetName = dataSetName;
  95. return this;
  96. }
  97.  
  98. public DataSetBOBuilder withId(final Long id) {
  99. this.id = id;
  100. return this;
  101. }
  102.  
  103. public DataSetBOBuilder withDataSetType(final String dataSetType) {
  104. this.dataSetType = DataSetType.valueOf(dataSetType.toUpperCase());
  105. return this;
  106. }
  107.  
  108. public DataSetBOBuilder withDataSetType(final DataSetType dataSetType) {
  109. this.dataSetType = dataSetType;
  110. return this;
  111. }
  112.  
  113. public DataSetBOBuilder withDataLot(final Long dataLot) {
  114. this.dataLot = dataLot;
  115. return this;
  116. }
  117.  
  118. public DataSetBOBuilder withReferenceDate(final LocalDate referenceDate) {
  119. this.referenceDate = referenceDate;
  120. return this;
  121. }
  122.  
  123. public DataSetBOBuilder withInputDataReference(final Long inputDataReference) {
  124. this.inputDataReference = inputDataReference;
  125. return this;
  126. }
  127.  
  128. public DataSetBOBuilder withAssignedSubmissions(final int assignedSubmissions) {
  129. this.assignedSubmissions = assignedSubmissions;
  130. return this;
  131. }
  132.  
  133. public DataSetBOBuilder withAllocatedSubmissions(final int allocatedSubmissions) {
  134. this.allocatedSubmissions = allocatedSubmissions;
  135. return this;
  136. }
  137.  
  138. public DataSetBO build() {
  139. if (Objects.isNull(this.dataSetType)) {
  140. this.dataSetType = Objects.isNull(this.inputDataReference) ? DataSetType.INPUT : DataSetType.ENRICHED;
  141. }
  142.  
  143. return new DataSetBO(this);
  144. }
  145. }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement