package com.bytedance.cukaie.closet.internal;

import X.8nq;
import X.M12;
import X.N3L;
import X.N3M;
import X.N3N;
import X.N3O;
import com.bytedance.covode.number.Covode;
import java.lang.reflect.Proxy;
import kotlin.h.b.n;

public final class ReflectiveClosetFactory implements 8nq {
    public final Class<?> clazz;
    public final N3O closetAnnotation;

    static {
        Covode.recordClassIndex(25685);
    }

    public final String closetName() {
        return this.closetAnnotation.LIZ();
    }

    public final Object createCloset(N3L n3l) {
        M12.LIZ(n3l);
        Object newProxyInstance = Proxy.newProxyInstance(this.clazz.getClassLoader(), new Class[]{this.clazz}, new N3M(n3l));
        n.LIZ(newProxyInstance, "");
        return newProxyInstance;
    }

    public ReflectiveClosetFactory(Class<?> cls) {
        M12.LIZ(cls);
        this.clazz = cls;
        N3O n3o = (N3O) cls.getAnnotation(N3O.class);
        if (n3o != null) {
            this.closetAnnotation = n3o;
            return;
        }
        throw new N3N("Couldn't find @Closet annotation on class " + cls.getCanonicalName());
    }
}
