/
MapStructure.java
46 lines (38 loc) 路 961 Bytes
/
MapStructure.java
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
44
45
46
package com.preference;
import java.util.AbstractMap;
/**
* Created by Ali Asadi on 19/08/2019.
*/
public class MapStructure {
private Class type;
private Class key;
private Class value;
private MapStructure(Class type, Class key, Class value) {
this.type = type;
this.key = key;
this.value = value;
}
/**
* For example HashMap<String,Object>
*
* type = HashMap.class
* key = String.class
* value = Object.class
*
* @param type - map type (HashMap, TreeMap...etc)
* @param key - map key
* @param value - map value
*/
public static <T extends AbstractMap> MapStructure create(Class<T> type, Class key, Class value) {
return new MapStructure(type, key, value);
}
public Class getType() {
return type;
}
public Class getKey() {
return key;
}
public Class getValue() {
return value;
}
}