All Downloads are FREE. Search and download functionalities are using the official Maven repository.

icasue.reflect.handles.enums.EnumOF Maven / Gradle / Ivy

package icasue.reflect.handles.enums;

import icasue.reflect.exceptions.HandleException;
import icasue.reflect.handles.HandleSupplier;
import icasue.reflect.handles.OFAble;
import icasue.reflect.handles.classes.ClassOF;
import icasue.reflect.handles.exception.ExceptionOF;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2020/11/30 下午12:00
 * @UpdateDate:
 * @Description:
 */
public class EnumOF implements OFAble {

    /**
     * getInstanceByTypeAndName_    (eType,eIdentityName)
     *
     * All method check pass.
     */

    public static HandleSupplier.FunctionAry getInstanceByTypeAndName_ = (clsAndInstanceName) -> {
        try {
            if(clsAndInstanceName.length != 2)
                throw ExceptionOF.handleExcInvocation_.apply("EnumOF.getInstanceByTypeAndName_ : required 2 params.");
            if(ClassOF.isEnum_.test(clsAndInstanceName[0]))
                return EnumO.getInstanceByTypeAndName.invoke(clsAndInstanceName[0],clsAndInstanceName[1]);
            else
                throw ExceptionOF.handleExcInvocation_.apply("EnumOF.getInstanceByTypeAndName_ : params 1 which given is not a enum.");
        } catch (HandleException deepError){
            throw deepError;
        } catch (Throwable throwable) {
            throw ExceptionOF.handleExcInvocation_.apply("EnumOF.getInstanceByTypeAndName_ : occur an error : " , throwable.getMessage());
        }
    };

}