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

xxl.mathematica.map.Keys Maven / Gradle / Ivy

package xxl.mathematica.map;

import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;

/**
 * 键列表
 */
public class Keys {
    /**
     * 键的列表
     *
     * @param 
     * @param 
     * @param map
     * @return
     */
    public static  List keys(Map map) {
        return io.vavr.collection.HashSet.ofAll(map.keySet())
                .toJavaList();
    }

    /**
     * 获取对象的所有字段
     *
     * @param obj
     * @return
     */
    public static List keys(Object obj) {
        return keys(obj.getClass());
    }

    /**
     * 列出一个类的所有字段
     *
     * @param cls
     * @return
     */
    public static List keys(Class cls) {
        return io.vavr.collection.List.of(cls.getDeclaredFields())
                .map(Field::getName)
                .asJava();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy