refactor: add lombok to businessdate module
This commit is contained in:
committed by
Arnold Gálovics
parent
41e6edcfa2
commit
cce97aaf1a
+8
-11
@@ -20,26 +20,23 @@ package org.apache.fineract.infrastructure.businessdate.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
|
||||
@ToString
|
||||
@Getter
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class BusinessDateData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String description;
|
||||
private String type;
|
||||
private LocalDate date;
|
||||
|
||||
public BusinessDateData(BusinessDateType businessDateType, LocalDate date) {
|
||||
this.type = businessDateType.getName();
|
||||
this.description = businessDateType.getDescription();
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public static BusinessDateData instance(BusinessDateType businessDateType, LocalDate value) {
|
||||
return new BusinessDateData(businessDateType, value);
|
||||
return new BusinessDateData().setType(businessDateType.getName()).setDate(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-13
@@ -28,9 +28,15 @@ import javax.persistence.UniqueConstraint;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Entity
|
||||
@Table(name = "m_business_date", uniqueConstraints = { @UniqueConstraint(name = "uq_business_date_type", columnNames = { "type" }) })
|
||||
public class BusinessDate extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
@@ -45,20 +51,8 @@ public class BusinessDate extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
@Version
|
||||
private Long version;
|
||||
|
||||
protected BusinessDate() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
protected BusinessDate(@NotNull BusinessDateType type, @NotNull LocalDate date) {
|
||||
this.type = type;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public static BusinessDate instance(@NotNull BusinessDateType businessDateType, @NotNull LocalDate date) {
|
||||
return new BusinessDate(businessDateType, date);
|
||||
return new BusinessDate().setType(businessDateType).setDate(date);
|
||||
}
|
||||
|
||||
public void updateDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import org.mapstruct.Mappings;
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface BusinessDateMapper {
|
||||
|
||||
@Mappings({ @Mapping(target = "businessDateType", source = "source.type"), @Mapping(target = "date", source = "source.date") })
|
||||
@Mappings({ @Mapping(target = "type", source = "source.type"), @Mapping(target = "date", source = "source.date") })
|
||||
BusinessDateData map(BusinessDate source);
|
||||
|
||||
List<BusinessDateData> map(List<BusinessDate> sources);
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class BusinessDateWritePlatformServiceImpl implements BusinessDateWritePl
|
||||
if (!hasChange(oldDate, newDate)) {
|
||||
return;
|
||||
}
|
||||
businessDate.updateDate(newDate);
|
||||
businessDate.setDate(newDate);
|
||||
repository.save(businessDate);
|
||||
changes.put(businessDate.getType().name(), newDate);
|
||||
}
|
||||
|
||||
+10
-19
@@ -27,6 +27,9 @@ import java.time.OffsetDateTime;
|
||||
import java.util.Optional;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.springframework.data.domain.Auditable;
|
||||
import org.springframework.data.jpa.domain.AbstractAuditable;
|
||||
@@ -39,21 +42,28 @@ import org.springframework.data.jpa.domain.AbstractAuditable;
|
||||
* Abstract base class for auditable entities. Stores the audit values in persistent fields.
|
||||
*/
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public abstract class AbstractAuditableWithUTCDateTimeCustom extends AbstractPersistableCustom
|
||||
implements Auditable<Long, Long, OffsetDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 141481953116476081L;
|
||||
|
||||
@Column(name = CREATED_BY_DB_FIELD, nullable = false)
|
||||
@Setter(onMethod = @__(@Override))
|
||||
private Long createdBy;
|
||||
|
||||
@Column(name = CREATED_DATE_DB_FIELD, nullable = false)
|
||||
@Setter(onMethod = @__(@Override))
|
||||
private OffsetDateTime createdDate;
|
||||
|
||||
@Column(name = LAST_MODIFIED_BY_DB_FIELD, nullable = false)
|
||||
@Setter(onMethod = @__(@Override))
|
||||
private Long lastModifiedBy;
|
||||
|
||||
@Column(name = LAST_MODIFIED_DATE_DB_FIELD, nullable = false)
|
||||
@Setter(onMethod = @__(@Override))
|
||||
private OffsetDateTime lastModifiedDate;
|
||||
|
||||
@Override
|
||||
@@ -61,11 +71,6 @@ public abstract class AbstractAuditableWithUTCDateTimeCustom extends AbstractPer
|
||||
return Optional.ofNullable(this.createdBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreatedBy(final Long createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<OffsetDateTime> getCreatedDate() {
|
||||
if (this.createdDate == null) {
|
||||
@@ -76,21 +81,11 @@ public abstract class AbstractAuditableWithUTCDateTimeCustom extends AbstractPer
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreatedDate(final OffsetDateTime createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Long> getLastModifiedBy() {
|
||||
return Optional.ofNullable(this.lastModifiedBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastModifiedBy(final Long lastModifiedBy) {
|
||||
this.lastModifiedBy = lastModifiedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<OffsetDateTime> getLastModifiedDate() {
|
||||
if (this.lastModifiedDate == null) {
|
||||
@@ -101,8 +96,4 @@ public abstract class AbstractAuditableWithUTCDateTimeCustom extends AbstractPer
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastModifiedDate(final OffsetDateTime lastModifiedDate) {
|
||||
this.lastModifiedDate = lastModifiedDate;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user