本文整理汇总了Java中com.hazelcast.config.MultiMapConfig类的典型用法代码示例。如果您正苦于以下问题:Java MultiMapConfig类的具体用法?Java MultiMapConfig怎么用?Java MultiMapConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultiMapConfig类属于com.hazelcast.config包,在下文中一共展示了MultiMapConfig类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testContains
import com.hazelcast.config.MultiMapConfig; //导入依赖的package包/类
@Test
public void testContains() throws Exception {
IMap<String, ComplexValue> map = Hazelcast.getMap("testContains");
MultiMap<String, ComplexValue> multiMap = Hazelcast.getMultiMap("testContains");
assertNull(map.put("1", new ComplexValue("text", 1)));
assertTrue(map.containsValue(new ComplexValue("text", 2)));
assertFalse(map.replace("1", new ComplexValue("text1", 1), new ComplexValue("text3", 5)));
ComplexValue v = map.get("1");
assertTrue(v.name.equals("text"));
assertTrue(v.time == 1);
assertTrue(map.replace("1", new ComplexValue("text", 2), new ComplexValue("text2", 5)));
v = map.get("1");
assertTrue(v.name.equals("text2"));
assertTrue(v.time == 5);
assertFalse(map.remove("1", new ComplexValue("text1", 5)));
v = map.get("1");
assertTrue(v.name.equals("text2"));
assertTrue(v.time == 5);
assertTrue(map.remove("1", new ComplexValue("text2", 6)));
assertNull(map.get("1"));
// Now MultiMap
assertTrue(multiMap.put("1", new ComplexValue("text", 1)));
assertFalse(multiMap.put("1", new ComplexValue("text", 1)));
assertFalse(multiMap.put("1", new ComplexValue("text", 2)));
assertTrue(multiMap.containsValue(new ComplexValue("text", 1)));
assertTrue(multiMap.containsValue(new ComplexValue("text", 2)));
assertTrue(multiMap.remove("1", new ComplexValue("text", 3)));
assertFalse(multiMap.remove("1", new ComplexValue("text", 1)));
assertTrue(multiMap.put("1", new ComplexValue("text", 1)));
assertTrue(multiMap.containsEntry("1", new ComplexValue("text", 1)));
assertTrue(multiMap.containsEntry("1", new ComplexValue("text", 2)));
assertTrue(multiMap.remove("1", new ComplexValue("text", 1)));
//Now MultiMap List
MultiMapConfig multiMapConfigList = new MultiMapConfig();
multiMapConfigList.setName("testContains.list");
multiMapConfigList.setValueCollectionType("LIST");
Hazelcast.getConfig().addMultiMapConfig(multiMapConfigList);
MultiMap<String, ComplexValue> mmList = Hazelcast.getMultiMap("testContains.list");
assertTrue(mmList.put("1", new ComplexValue("text", 1)));
assertTrue(mmList.put("1", new ComplexValue("text", 1)));
assertTrue(mmList.put("1", new ComplexValue("text", 2)));
assertEquals(3, mmList.size());
assertTrue(mmList.remove("1", new ComplexValue("text", 4)));
assertEquals(2, mmList.size());
}