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

io.github.jinghui70.rainbow.dbaccess.enumSupport.CodeEnum Maven / Gradle / Ivy

The newest version!
package io.github.jinghui70.rainbow.dbaccess.enumSupport;

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

/**
 * 标记枚举值在存到数据库的时候,保存其 code
 */
public interface CodeEnum {

    String code();

    static  & CodeEnum> T codeToEnum(Class enumClass, String code) {
        return Arrays.stream(enumClass.getEnumConstants())
                .filter(e -> Objects.equals(code, e.code()))
                .findAny().orElse(null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy