com.maxifier.mxcache.impl.caches.batch.ListKeyStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mxcache-runtime Show documentation
Show all versions of mxcache-runtime Show documentation
Constains all classes necessary for launching a MxCache-instrumentated application
/*
* Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
*/
package com.maxifier.mxcache.impl.caches.batch;
import java.util.ArrayList;
import java.util.List;
/**
* @author Alexander Kochurov ([email protected])
*/
final class ListKeyStrategy implements KeyStrategy, T, List> {
private ListKeyStrategy() {}
private static final ListKeyStrategy INSTANCE = new ListKeyStrategy();
public static ListKeyStrategy getInstance() {
//noinspection unchecked
return INSTANCE;
}
@Override
public int size(List key) {
return key.size();
}
@Override
public List iterator(List ts) {
return ts;
}
@Override
public T get(int order, List iterator) {
return iterator.get(order);
}
@Override
public List toKey(List ts, int count) {
return ts;
}
@Override
public boolean isStableOrder() {
return true;
}
@Override
public List create(List expectedType) {
return new ArrayList(expectedType.size());
}
@Override
public boolean put(List key, int index, T value) {
return key.add(value);
}
}