package com.sorakasugano.pasteboard;

import java.util.*;
import redis.clients.jedis.*;
import com.sorakasugano.pasteboard.Adapter;
import com.sorakasugano.pasteboard.Reader;
import com.sorakasugano.pasteboard.Getter;

public class Selector extends Reader<List<Map<String, String>>> {
    public String subtype = null;
    public String alias = null;
    public int offset = 0;
    public int limit = -1;
    private String list() {
        return (type == null ? "" : type + ":" + id + ":") + subtype + "-list";
    }
    @Override
    public List<Map<String, String>> call(Jedis jedis) throws Exception {
        Set<String> set = jedis.zrevrange(list(), offset, limit < 0 ? -1 : offset + limit);
        List<Map<String, String>> out = new LinkedList<Map<String, String>>();
        for (String id : set) {
            Getter getter = new Getter();
            getter.type = alias == null ? subtype : alias;
            getter.id = id;
            out.add(Adapter.invoke(getter));
        }
        return out;
    }
}

@@ -160,21 +160,20 @@
 teboard.
-Reade
+Acto
 r;%0Aimpor
@@ -245,13 +245,12 @@
 nds 
-Reade
+Acto
 r%3CLi
@@ -1011,10 +1011,175 @@
 ;%0A    %7D%0A
+    @Override%0A    public Map%3CString, Boolean%3E keys() %7B%0A        Map%3CString, Boolean%3E keys = super.keys();%0A        keys.put(list(), false);%0A        return keys;%0A    %7D%0A
 %7D%0A

remove useless read lock