| 25 | import org.jetbrains.annotations.NotNull; |
| 26 | |
| 27 | public class Rank extends AbstractRank { |
| 28 | private final AppBase app; |
| 29 | protected static final BeanFactory beanFactory = new BeanFactory(); |
| 30 | |
| 31 | private volatile IntUnaryOperator funcRankSize; |
| 32 | private volatile IntUnaryOperator funcConcurrentLevel; |
| 33 | private volatile LongUnaryOperator funcRankCacheTimeout; |
| 34 | |
| 35 | @SuppressWarnings("CanBeFinal") |
| 36 | private volatile float computeFactor = 2.5f; |
| 37 | private volatile Comparator<Bean> compactor = new LongOnlyCompactor(); |
| 38 | |
| 39 | public static class LongOnlyCompactor implements Comparator<Bean> { |
| 40 | @Override |
| 41 | public int compare(Bean o1, Bean o2) { |
| 42 | if (o1.typeId() == BValueLong.TYPEID) |
| 43 | return Long.compare(((BValueLong)o1).getValue(), ((BValueLong)o2).getValue()); |
| 44 | throw new RuntimeException("unknown compactor bean"); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | public void setFuncConcurrentLevel(IntUnaryOperator funcConcurrentLevel) { |
| 49 | this.funcConcurrentLevel = funcConcurrentLevel; |
| 50 | } |
| 51 | |
| 52 | public IntUnaryOperator getFuncConcurrentLevel() { |
| 53 | return funcConcurrentLevel; |
| 54 | } |
| 55 | |
| 56 | public void setFuncRankCacheTimeout(LongUnaryOperator funcRankCacheTimeout) { |
| 57 | this.funcRankCacheTimeout = funcRankCacheTimeout; |
| 58 | } |
| 59 | |
| 60 | public LongUnaryOperator getFuncRankCacheTimeout() { |
| 61 | return funcRankCacheTimeout; |
| 62 | } |
| 63 | |
| 64 | public void setFuncRankSize(IntUnaryOperator funcRankSize) { |
| 65 | this.funcRankSize = funcRankSize; |
| 66 | } |
| 67 | |
| 68 | public IntUnaryOperator getFuncRankSize() { |
| 69 | return funcRankSize; |
| 70 | } |
| 71 | |
| 72 | public void setComputeFactor(float computeFactor) { |
| 73 | this.computeFactor = computeFactor; |
| 74 | } |
| 75 | |
| 76 | public float getComputeFactor() { |
| 77 | return computeFactor; |
| 78 | } |
| 79 | |
| 80 | public void setCompactor(Comparator<Bean> compactor) { |
| 81 | this.compactor = compactor; |
| 82 | } |
| 83 | |
| 84 | public Comparator<Bean> getCompactor() { |
nothing calls this directly
no outgoing calls
no test coverage detected