UcListUtils.java 1.27 KB
package com.topdraw.util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public class UcListUtils {

    public static boolean compareIntegerList(Integer obj , List<Integer> originList){
        Integer o = originList.get(0);
        Integer o1 = originList.get(1);

        if (o >= 0 && o1 > o && obj >= o && obj <= o1)
            return true;

        if (o > 0 && o1 < 0 && obj >= o)
            return true;

        return false;
    }

    public static void main(String[] args) {
        String param = "{CONTINUE_LOGIN:30}";
        Map<String,String> jsonObjectMap = JSONObject.parseObject(param,Map.class);
        Collection<String> values = jsonObjectMap.values();
        Object o = values.toArray()[0];

        String attrStr = "{\"value\":[31,-99]}";
        JSONObject jsonObject = JSONObject.parseObject(attrStr);
        JSONArray values_0 = jsonObject.getJSONArray("value");
        Integer o1 = (Integer)values_0.get(0);
        Integer o2 = (Integer)values_0.get(1);
        List<Integer> list = Arrays.asList(o1, o2);
        Integer i = (Integer) o;
        boolean b = compareIntegerList(i, list);
        System.out.println(b);
    }

}