/** * Creates a map which decorates the given <code>map</code> and * creates the value collections using the supplied <code>collectionFactory</code>. * * @param map the map to decorate * @param collectionFactory the collection factory (must return a Collection object). */ public static MultiValueMap decorate(Map map, Factory collectionFactory) { return new MultiValueMap(map, collectionFactory); }
/** * Creates a map which decorates the given <code>map</code> and * creates the value collections using the supplied <code>collectionFactory</code>. * * @param map the map to decorate * @param collectionFactory the collection factory (must return a Collection object). */ public static MultiValueMap decorate(Map map, Factory collectionFactory) { return new MultiValueMap(map, collectionFactory); }
@Override public Map<String, CategoryAttribute> getMultiValueCategoryAttributes() { Map<String, CategoryAttribute> multiValueMap = new MultiValueMap(); for (CategoryAttribute categoryAttribute : categoryAttributes) { multiValueMap.put(categoryAttribute.getName(), categoryAttribute); } return multiValueMap; }
@Override public Map<String, ProductAttribute> getMultiValueProductAttributes() { Map<String, ProductAttribute> multiValueMap = new MultiValueMap(); for (ProductAttribute productAttribute : productAttributes) { multiValueMap.put(productAttribute.getName(), productAttribute); } return multiValueMap; }
/** * Creates a map which wraps the given map and * maps keys to ArrayLists. * * @param map the map to wrap */ public static MultiValueMap decorate(Map map) { return new MultiValueMap(map, new ReflectionFactory(ArrayList.class)); }
/** * Creates a map which decorates the given <code>map</code> and * maps keys to collections of type <code>collectionClass</code>. * * @param map the map to wrap * @param collectionClass the type of the collection class */ public static MultiValueMap decorate(Map map, Class collectionClass) { return new MultiValueMap(map, new ReflectionFactory(collectionClass)); }
/** * Creates a map which decorates the given <code>map</code> and * maps keys to collections of type <code>collectionClass</code>. * * @param map the map to wrap * @param collectionClass the type of the collection class */ public static MultiValueMap decorate(Map map, Class collectionClass) { return new MultiValueMap(map, new ReflectionFactory(collectionClass)); }
/** * Creates a map which wraps the given map and * maps keys to ArrayLists. * * @param map the map to wrap */ public static MultiValueMap decorate(Map map) { return new MultiValueMap(map, new ReflectionFactory(ArrayList.class)); }
@Override @SuppressWarnings("unchecked") public Map<String, Collection<SkuAttribute>> getMultiValueSkuAttributes() { MultiValueMap multiValueMap = new MultiValueMap(); for (SkuAttribute skuAttribute : skuAttributes) { multiValueMap.put(skuAttribute.getName(), skuAttribute); } return multiValueMap; }
public void testMapEquals() { MultiValueMap one = new MultiValueMap(); Integer value = new Integer(1); one.put("One", value); one.remove("One", value); MultiValueMap two = new MultiValueMap(); assertEquals(two, one); }
@Override public Map<String, List<PromotionMessageDTO>> convertPromotionMessagesToDTOs(Set<PromotionMessage> promotionMessages, Offer offer) { MultiValueMap promotionMessageDTOs = new MultiValueMap(); for (PromotionMessage message : promotionMessages) { PromotionMessageDTO dto = new PromotionMessageDTO(message); CustomerRuleHolder customerRuleHolder = buildCustomerRuleHolder(offer); dto.setCustomerRuleHolder(customerRuleHolder); promotionMessageDTOs.put(dto.getMessagePlacement(), dto); } return promotionMessageDTOs; }
public void testIterator_Key() { MultiValueMap map = new MultiValueMap(); assertEquals(false, map.iterator("A").hasNext()); map.put("A", "AA"); Iterator it = map.iterator("A"); assertEquals(true, it.hasNext()); it.next(); assertEquals(false, it.hasNext()); }
public void testGetCollection() { MultiValueMap map = new MultiValueMap(); map.put("A", "AA"); assertSame(map.get("A"), map.getCollection("A")); }
public void testPut_ReturnValue() { MultiValueMap test = new MultiValueMap(); assertNotNull(test.put("key", "object1")); assertNotNull(test.put("key", "object2")); List coll = Arrays.asList(new String[]{"uno", "un"}); assertTrue(test.putAll("key", coll)); assertFalse(test.putAll("key", new ArrayList())); }
public void testRemove_KeyItem() { MultiValueMap map = new MultiValueMap(); map.put("A", "AA"); map.put("A", "AB"); map.put("A", "AC"); assertEquals(null, map.remove("C", "CA")); assertEquals(null, map.remove("A", "AD")); assertEquals("AC", map.remove("A", "AC")); assertEquals("AB", map.remove("A", "AB")); assertEquals("AA", map.remove("A", "AA")); assertEquals(new MultiValueMap(), map); }
public void testPutAll_Map2() { Map original = new HashMap(); original.put("keyX", "object1"); original.put("keyY", "object2"); MultiValueMap test = new MultiValueMap(); test.put("keyA", "objectA"); test.put("keyX", "object0"); test.putAll(original); assertEquals(3, test.size()); assertEquals(4, test.totalSize()); assertEquals(1, test.getCollection("keyA").size()); assertEquals(2, test.getCollection("keyX").size()); assertEquals(1, test.getCollection("keyY").size()); assertEquals(true, test.containsValue("objectA")); assertEquals(true, test.containsValue("object0")); assertEquals(true, test.containsValue("object1")); assertEquals(true, test.containsValue("object2")); }
public void testPutAll_Map1() { MultiMap original = new MultiValueMap(); original.put("key", "object1"); original.put("key", "object2"); MultiValueMap test = new MultiValueMap(); test.put("keyA", "objectA"); test.put("key", "object0"); test.putAll(original); assertEquals(2, test.size()); assertEquals(4, test.totalSize()); assertEquals(1, test.getCollection("keyA").size()); assertEquals(3, test.getCollection("key").size()); assertEquals(true, test.containsValue("objectA")); assertEquals(true, test.containsValue("object0")); assertEquals(true, test.containsValue("object1")); assertEquals(true, test.containsValue("object2")); }
public void testContainsValue_Key() { MultiValueMap map = new MultiValueMap(); assertEquals(false, map.containsValue("A", "AA")); assertEquals(false, map.containsValue("B", "BB")); map.put("A", "AA"); assertEquals(true, map.containsValue("A", "AA")); assertEquals(false, map.containsValue("A", "AB")); }
public void testSize() { MultiValueMap map = new MultiValueMap(); assertEquals(0, map.size()); map.put("A", "AA"); assertEquals(1, map.size()); map.put("B", "BA"); assertEquals(2, map.size()); map.put("B", "BB"); assertEquals(2, map.size()); map.put("B", "BC"); assertEquals(2, map.size()); map.remove("A"); assertEquals(2, map.size()); map.remove("B", "BC"); assertEquals(2, map.size()); }
public void testTotalSize() { MultiValueMap map = new MultiValueMap(); assertEquals(0, map.totalSize()); map.put("A", "AA"); assertEquals(1, map.totalSize()); map.put("B", "BA"); assertEquals(2, map.totalSize()); map.put("B", "BB"); assertEquals(3, map.totalSize()); map.put("B", "BC"); assertEquals(4, map.totalSize()); map.remove("A"); assertEquals(3, map.totalSize()); map.remove("B", "BC"); assertEquals(2, map.totalSize()); }