package com.lynx.jsbridge;

import X.C4260Lh5;
import X.C4262Lh7;
import X.ITb;
import com.bytedance.covode.number.Covode;
import com.lynx.react.bridge.JavaOnlyArray;
import com.lynx.tasm.base.LLog;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class LynxModuleWrapper {
    public final LynxModule LIZ;
    public final ArrayList<MethodDescriptor> LIZIZ = new ArrayList<>();
    public final ArrayList<AttributeDescriptor> LIZJ = new ArrayList<>();
    public final String LIZLLL;

    static {
        Covode.recordClassIndex(46293);
    }

    public LynxModule getModule() {
        return this.LIZ;
    }

    public String getName() {
        return this.LIZLLL;
    }

    public Collection<MethodDescriptor> getMethodDescriptors() {
        if (this.LIZIZ.isEmpty()) {
            try {
                HashSet hashSet = new HashSet();
                for (Method method : this.LIZ.getClass().getDeclaredMethods()) {
                    if (method.getAnnotation(ITb.class) != null) {
                        String name = method.getName();
                        if (!hashSet.contains(name)) {
                            hashSet.add(name);
                            MethodDescriptor methodDescriptor = new MethodDescriptor();
                            C4260Lh5 lh5 = new C4260Lh5(method);
                            methodDescriptor.LIZJ = name;
                            methodDescriptor.LIZIZ = lh5.LIZ();
                            methodDescriptor.LIZ = method;
                            this.LIZIZ.add(methodDescriptor);
                        } else {
                            throw new IllegalArgumentException("Java Module " + getName() + " method name already registered: " + name);
                        }
                    }
                }
            } catch (RuntimeException e) {
                LLog.LIZ(6, "LynxModuleWrapper", e.toString());
            }
        }
        return this.LIZIZ;
    }

    public Collection<AttributeDescriptor> getAttributeDescriptor() {
        if (this.LIZJ.isEmpty()) {
            try {
                HashSet hashSet = new HashSet();
                for (Field field : this.LIZ.getClass().getDeclaredFields()) {
                    if (((C4262Lh7) field.getAnnotation(C4262Lh7.class)) != null) {
                        String name = field.getName();
                        if (!hashSet.contains(name)) {
                            hashSet.add(name);
                            AttributeDescriptor attributeDescriptor = new AttributeDescriptor();
                            attributeDescriptor.LIZ = name;
                            attributeDescriptor.LIZIZ = new JavaOnlyArray();
                            try {
                                attributeDescriptor.LIZIZ.add(field.get(this.LIZ));
                            } catch (IllegalAccessException e) {
                                LLog.LIZ(6, "LynxModuleWrapper", e.toString());
                            }
                            this.LIZJ.add(attributeDescriptor);
                        } else {
                            throw new IllegalArgumentException("Java Module " + getName() + " attribute name already registered: " + name);
                        }
                    }
                }
            } catch (RuntimeException e2) {
                LLog.LIZ(6, "LynxModuleWrapper", e2.toString());
            }
        }
        return this.LIZJ;
    }

    public LynxModuleWrapper(String str, LynxModule lynxModule) {
        this.LIZLLL = str;
        this.LIZ = lynxModule;
    }
}
