refactor: add lombok to cache module

This commit is contained in:
Hemant Gupta
2022-09-13 14:46:19 +02:00
committed by Arnold Gálovics
parent cce97aaf1a
commit e67b859ea1
3 changed files with 18 additions and 19 deletions
@@ -18,21 +18,23 @@
*/
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;
@Data
@NoArgsConstructor
@Accessors(chain = true)
public final class CacheData {
@SuppressWarnings("unused")
private final EnumOptionData cacheType;
private EnumOptionData cacheType;
@SuppressWarnings("unused")
private final boolean enabled;
private 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;
}
}
@@ -21,23 +21,23 @@ package org.apache.fineract.infrastructure.cache.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
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;
@Entity
@Table(name = "c_cache")
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class PlatformCache extends AbstractPersistableCustom {
@Column(name = "cache_type_enum")
private Integer cacheType;
protected PlatformCache() {
this.cacheType = null;
}
public PlatformCache(final CacheType cacheType) {
this.cacheType = cacheType.getValue();
}
public boolean isNoCachedEnabled() {
return CacheType.fromInt(this.cacheType).isNoCache();
}
@@ -50,7 +50,4 @@ public class PlatformCache extends AbstractPersistableCustom {
return CacheType.fromInt(this.cacheType).isDistributedCache();
}
public void update(final CacheType cacheType) {
this.cacheType = cacheType.getValue();
}
}
@@ -124,7 +124,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
@Override
public void updateCache(final CacheType cacheType) {
this.cacheTypeRepository.findById(1L).ifPresent(cache -> {
cache.update(cacheType);
cache.setCacheType(cacheType.getValue());
this.cacheTypeRepository.save(cache);
});
}