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

io.github.yezhihao.netmc.util.AdapterList Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
package io.github.yezhihao.netmc.util;

import java.util.AbstractList;
import java.util.List;
import java.util.function.Function;

/**
 * @author yezhihao
 * home https://gitee.com/yezhihao/jt808-server
 */
public final class AdapterList extends AbstractList {

    private final List src;
    private final Function function;

    public AdapterList(List src, Function function) {
        this.src = src;
        this.function = function;
    }

    @Override
    public T get(int index) {
        return function.apply(src.get(index));
    }

    @Override
    public int size() {
        return src.size();
    }
}