package com.sunyard.chsm.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author liulu
 * @since 2024/10/17
 */
@Getter
@AllArgsConstructor
public enum ManufacturerModelEnum {

    enc001(ManufacturerEnum.SUNYARD, "SYD-001", "服务器密码机"),
    ;

    private final ManufacturerEnum manufacturer;
    private final String model;
    private final String name;

    public static ManufacturerModelEnum of(String code) {
        if (code == null || code.trim().isEmpty()) {
            return null;
        }

        return Arrays.stream(ManufacturerModelEnum.values())
                .filter(it -> Objects.equals(it.model, code))
                .findFirst()
                .orElse(null);
    }

}
