/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.io.WhirlycacheFactory
 *  com.l7tech.util.Cacheable
 *  com.l7tech.util.TimeSource
 *  com.whirlycott.cache.Cache
 *  org.springframework.beans.factory.config.AbstractFactoryBean
 */
package com.l7tech.server.util;

import com.l7tech.common.io.WhirlycacheFactory;
import com.l7tech.server.util.f;
import com.l7tech.server.util.h;
import com.l7tech.util.Cacheable;
import com.l7tech.util.TimeSource;
import com.whirlycott.cache.Cache;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.logging.Logger;
import org.springframework.beans.factory.config.AbstractFactoryBean;

public class EntityCachingFactoryBean
extends AbstractFactoryBean {
    private static final Logger a;
    private final TimeSource b;
    private final String c;
    private final Class d;
    private final Object e;
    private Cache f;
    private static final String[] g;

    public EntityCachingFactoryBean(Class clazz, Object object) {
        this(new TimeSource(), null, clazz, object);
    }

    public EntityCachingFactoryBean(TimeSource timeSource, String string, Class clazz, Object object) {
        String string2;
        TimeSource timeSource2;
        if (clazz == null) {
            String[] stringArray = g;
            throw new IllegalArgumentException(stringArray[0]);
        }
        try {
            if (object == null) {
                throw new IllegalArgumentException(g[1]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw EntityCachingFactoryBean.a(illegalArgumentException);
        }
        try {
            EntityCachingFactoryBean entityCachingFactoryBean = this;
            timeSource2 = timeSource == null ? new TimeSource() : timeSource;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw EntityCachingFactoryBean.a(illegalArgumentException);
        }
        try {
            entityCachingFactoryBean.b = timeSource2;
            EntityCachingFactoryBean entityCachingFactoryBean = this;
            string2 = string == null ? g[2] : string;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw EntityCachingFactoryBean.a(illegalArgumentException);
        }
        entityCachingFactoryBean.c = string2;
        this.d = clazz;
        this.e = object;
    }

    public Class getObjectType() {
        return this.d;
    }

    protected Object createInstance() throws Exception {
        try {
            if (this.f == null) {
                this.f = WhirlycacheFactory.createCache((String)(this.c + "-" + this.d.getName()), (int)1000, (int)63, (String)WhirlycacheFactory.POLICY_LRU);
            }
        }
        catch (Exception exception) {
            throw EntityCachingFactoryBean.a(exception);
        }
        return Proxy.newProxyInstance(EntityCachingFactoryBean.class.getClassLoader(), new Class[]{this.d}, this.a());
    }

    private InvocationHandler a() {
        return new f(this);
    }

    private h a(Cacheable cacheable, Object[] objectArray, Method method) {
        Object[] objectArray2 = new Object[]{};
        if (cacheable.relevantArg() >= 0) {
            objectArray2 = new Object[]{objectArray[cacheable.relevantArg()]};
        }
        return new h(method, objectArray2);
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "Kx\u0005e23\u0005qs\u0003v)6\u0001[xWz(p\u0012]l\u0002z)5\u0004\u001bKx\u0005e23\u0005qs\u0004g:>\u0003]=\u001e`{\"\u0005Ih\u001ea>4\u0007}P4r88\u0005";
        int n3 = "Kx\u0005e23\u0005qs\u0003v)6\u0001[xWz(p\u0012]l\u0002z)5\u0004\u001bKx\u0005e23\u0005qs\u0004g:>\u0003]=\u001e`{\"\u0005Ih\u001ea>4\u0007}P4r88\u0005".length();
        int n4 = 28;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = EntityCachingFactoryBean.a(62, EntityCachingFactoryBean.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                g = stringArray;
                a = Logger.getLogger(EntityCachingFactoryBean.class.getName());
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x5E);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 6;
                    case 1 -> 35;
                    case 2 -> 73;
                    case 3 -> 45;
                    case 4 -> 101;
                    case 5 -> 110;
                    default -> 94;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

