package com.zd.netty.enums;

import com.zd.netty.sdk.DeJuRFIDClientImpl;
import com.zd.netty.sdk.DeJuRFIDServerImpl;
import com.zd.netty.sdk.WuYuanRFIDServiceImpl;
import com.zd.netty.service.IService;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Administrator
 */

@Getter
@AllArgsConstructor
public enum ManufacturerTypeEnum {

    /**
     * 枚举常量
     */
    WU_WEI(1,"无源", WuYuanRFIDServiceImpl.class),
    DE_JU(2,"惠州德聚服务端", DeJuRFIDServerImpl.class),
    DE_JU2(3,"惠州德聚客户端", DeJuRFIDClientImpl.class);

    /**
     * 字典码
     */
    private final Integer code;
    /**
     * 供应厂商名称
     */
    private final String name;

    /**
     * 接口实现对象
     */
    private final Class<? extends IService> service;

    /**
     * 根据类型返回具体的SubjectType
     *
     * @param value value
     * @return SubjectType
     */
    public static ManufacturerTypeEnum matchByValue(Integer value) {
        for (ManufacturerTypeEnum item : ManufacturerTypeEnum.values()) {
            if (item.code.equals(value)) {
                return item;
            }
        }
        return WU_WEI;
    }

    /**
     * 根据描述返回具体的SubjectType
     *
     * @param name name
     * @return SubjectType
     */
    public static ManufacturerTypeEnum matchByName(String name) {
        for (ManufacturerTypeEnum item : ManufacturerTypeEnum.values()) {
            if (item.name.equals(name)) {
                return item;
            }
        }
        return WU_WEI;
    }
}
