All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.maxifier.mxcache.impl.caches.batch.ListKeyStrategy Maven / Gradle / Ivy

Go to download

Constains all classes necessary for launching a MxCache-instrumentated application

There is a newer version: 2.6.9
Show newest version
/*
 * 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy