Code example for Method

Methods: getAnnotation

0
    protected int getTimestampIndex() { 
        return 1; 
    } 
 
    public Serializable createKey(Object target, Method method, Object[] args) {
        Prefix prefix = method.getAnnotation(Prefix.class);
        return createKey(prefix != null ? prefix.value() : null, args[getKeyIndex()]);
    } 
 
    protected Serializable createKey(String prefix, Object arg) {
        return (prefix != null) ? prefix + arg : (Serializable) arg;
    } 
 
    public TimestampedListCachedResult wrap(List<E> orginal, Object target, Method method, Object[] args) {
        return new TimestampedListCachedResult((Long) args[getTimestampIndex()], orginal);
    } 
 
    public List<E> unwrap(TimestampedListCachedResult cached, Object target, Method method, Object[] args) {
        List<Long> ids = cached.getSubList((Long) args[getTimestampIndex()]);
        return getEntities(ids);
    }