refactor: add lombok to cache module
This commit is contained in:
committed by
Arnold Gálovics
parent
cce97aaf1a
commit
e67b859ea1
Vendored
+9
-7
@@ -18,21 +18,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.infrastructure.cache.data;
|
package org.apache.fineract.infrastructure.cache.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class CacheData {
|
public final class CacheData {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final EnumOptionData cacheType;
|
private EnumOptionData cacheType;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
public static CacheData instance(final EnumOptionData cacheType, final boolean enabled) {
|
public static CacheData instance(final EnumOptionData cacheType, final boolean enabled) {
|
||||||
return new CacheData(cacheType, enabled);
|
return new CacheData().setCacheType(cacheType).setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CacheData(final EnumOptionData cacheType, final boolean enabled) {
|
|
||||||
this.cacheType = cacheType;
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+8
-11
@@ -21,23 +21,23 @@ package org.apache.fineract.infrastructure.cache.domain;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "c_cache")
|
@Table(name = "c_cache")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class PlatformCache extends AbstractPersistableCustom {
|
public class PlatformCache extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@Column(name = "cache_type_enum")
|
@Column(name = "cache_type_enum")
|
||||||
private Integer cacheType;
|
private Integer cacheType;
|
||||||
|
|
||||||
protected PlatformCache() {
|
|
||||||
this.cacheType = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlatformCache(final CacheType cacheType) {
|
|
||||||
this.cacheType = cacheType.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNoCachedEnabled() {
|
public boolean isNoCachedEnabled() {
|
||||||
return CacheType.fromInt(this.cacheType).isNoCache();
|
return CacheType.fromInt(this.cacheType).isNoCache();
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,4 @@ public class PlatformCache extends AbstractPersistableCustom {
|
|||||||
return CacheType.fromInt(this.cacheType).isDistributedCache();
|
return CacheType.fromInt(this.cacheType).isDistributedCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(final CacheType cacheType) {
|
|
||||||
this.cacheType = cacheType.getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -124,7 +124,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
@Override
|
@Override
|
||||||
public void updateCache(final CacheType cacheType) {
|
public void updateCache(final CacheType cacheType) {
|
||||||
this.cacheTypeRepository.findById(1L).ifPresent(cache -> {
|
this.cacheTypeRepository.findById(1L).ifPresent(cache -> {
|
||||||
cache.update(cacheType);
|
cache.setCacheType(cacheType.getValue());
|
||||||
this.cacheTypeRepository.save(cache);
|
this.cacheTypeRepository.save(cache);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user