com.mageddo.commons.caching.internal.WrapperIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-lang Show documentation
Show all versions of commons-lang Show documentation
A set of useful classes, evicting you repeating yourself, avoiding fatigue
The newest version!
package com.mageddo.commons.caching.internal;
import java.time.LocalDateTime;
import java.util.Comparator;
import lombok.EqualsAndHashCode;
import lombok.Value;
@Value
@EqualsAndHashCode(of = "key")
public class WrapperIndex {
private String key;
private Wrapper wrapper;
public static WrapperIndex of(String key, Wrapper w) {
return new WrapperIndex(key, w);
}
public static Comparator leastUsedIndex() {
return Comparator.comparingInt(WrapperIndex::getAccesses);
}
public static Comparator expirationIndex() {
return Comparator.comparing(WrapperIndex::willExpireAt);
}
int getAccesses() {
return this.wrapper.getAccesses();
}
LocalDateTime willExpireAt(){
return this.wrapper.getExpiresAt();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy