You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
package com.tptj.demo.hg.connection.store; |
|
|
|
import java.util.HashMap; |
|
import java.util.Map; |
|
|
|
/** |
|
* @author 秃破天际 |
|
* @version 10.0 |
|
* Created by 秃破天际 on 2021-03-31 |
|
* 模拟数据源 |
|
**/ |
|
public class Store { |
|
private Map<String, Data> store = new HashMap<String,Data>(3); |
|
private static Store instance = null; |
|
private Store(){ } |
|
|
|
public boolean contains(String key){ |
|
return store.containsKey(key); |
|
} |
|
|
|
public Data get(String key){ |
|
return store.get(key); |
|
} |
|
|
|
private void load(){ |
|
store.put("key1",new Data(new String[]{"k1","k2","k3"}, |
|
new String[][]{ |
|
{"v11","v12","v13"}, |
|
{"v21","v22","v23"}, |
|
{"v31","v32","v33"} |
|
} )); |
|
store.put("key2",new Data(new String[]{"k4","k5"}, |
|
new String[][]{ |
|
{"n11","n12"}, |
|
{"n21","n22"}, |
|
{"n31","n32"} |
|
} )); |
|
store.put("key3",new Data(new String[]{"k6","k7","k3","k8"}, |
|
new String[][]{ |
|
{"x11","x12","x13","x14"}, |
|
{"x21","x22","x23","x24"}, |
|
{"x31","x32","x33","x34"} |
|
} )); |
|
} |
|
|
|
public static Store getInstance(){ |
|
if( null == instance ){ |
|
synchronized (Store.class){ |
|
if( null == instance ){ |
|
instance = new Store(); |
|
instance.load(); |
|
} |
|
} |
|
} |
|
return instance; |
|
} |
|
}
|
|
|