UcListUtils.java
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}
}