@@ -0,0 +1,2081 @@
+package com.github.bingoohuang.westcache.utils;%0A%0Aimport com.github.bingoohuang.westcache.base.ExpireAfterWritable;%0Aimport com.github.bingoohuang.westcache.base.ExpireAfterWrite;%0Aimport lombok.extern.slf4j.Slf4j;%0Aimport lombok.val;%0A%0Aimport java.lang.reflect.Method;%0Aimport java.lang.reflect.Modifier;%0A%0Aimport static org.apache.commons.lang3.StringUtils.isNotBlank;%0A%0A/**%0A * @author bingoohuang %5Bbingoohuang@gmail.com%5D Created on 2017/1/19.%0A */%0A@Slf4j%0Apublic abstract class ExpireAfterWrites %7B%0A    public static String parseExpireAfterWrite(WestCacheOption option, Object obj) %7B%0A        if (option == null) return null;%0A%0A        String expireWrite = option.getSpecs().get(%22expireAfterWrite%22);%0A        if (isNotBlank(expireWrite)) return expireWrite;%0A%0A        if (obj == null) return null;%0A        if (obj instanceof ExpireAfterWritable) %7B%0A            return ((ExpireAfterWritable) obj).expireAfterWrite();%0A        %7D%0A%0A        return getExpireAfterWrite(obj);%0A    %7D%0A%0A    public static String getExpireAfterWrite(Object object) %7B%0A        val m = findExpireAfterWriteMethod(object);%0A        return m == null ? null : (String) Envs.invoke(m, object);%0A    %7D%0A%0A    public static Method findExpireAfterWriteMethod(Object object) %7B%0A        val annClass = ExpireAfterWrite.class;%0A        for (Method m : object.getClass().getMethods()) %7B%0A            if (!m.isAnnotationPresent(annClass)) continue;%0A%0A            if (isNormalStringMethodWithoutArgs(m)) return m;%0A%0A            throw new RuntimeException(%22method %22%0A                    + m.getDeclaringClass().getSimpleName()%0A                    + %22.%22 + m.getName() + %22 is invalid for @%22%0A                    + annClass.getSimpleName());%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A    private static boolean isNormalStringMethodWithoutArgs(Method method) %7B%0A        if (Modifier.isStatic(method.getModifiers())) return false;%0A        if (!Modifier.isPublic(method.getModifiers())) return false;%0A        if (method.getParameterTypes().length != 0) return false;%0A        if (method.getReturnType() != String.class) return false;%0A        return true;%0A    %7D%0A%7D%0A

add ExpireAfterWrites