package net.northking.cctp.element.mobile.enums;

import com.alibaba.fastjson.JSON;
import io.appium.java_client.android.nativekey.AndroidKey;
import net.northking.cctp.element.core.type.EnumClass;

import java.util.*;

public enum KeyCode implements EnumClass {
    ENTER(AndroidKey.ENTER.getCode(),"回车"),
    ESC(AndroidKey.ESCAPE.getCode(), "返回"),
    TAB(AndroidKey.TAB.getCode(), "tab");

    private int code;
    private String name;

    KeyCode(int code,String name){
        this.code = code;
        this.name = name;
    }
    @Override
    public String getEnumData() {
        List<Map<String,Object>> result = new ArrayList<>();
        for (KeyCode nullEnum : EnumSet.allOf(KeyCode.class)) {
            Map<String,Object> one = new HashMap();
            one.put("label",nullEnum.name);
            one.put("value",nullEnum.code);
            result.add(one);
        }
        return JSON.toJSONString(result);
    }
}
