@Test public void testLoadMetaMap() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(new ByteArrayInputStream(XML.getBytes())); MultiValuedMap<String, SimpleMetaAttribute> mm = MetaAttributeHelper.loadMetaMap(document.getDocumentElement()); Assert.assertEquals(1, mm.size()); Collection<SimpleMetaAttribute> attributeList = mm.get("blah"); Assert.assertEquals(1, attributeList.size()); Optional<SimpleMetaAttribute> first = attributeList.stream().findFirst(); Assert.assertTrue(first.isPresent()); SimpleMetaAttribute attribute = first.get(); Assert.assertEquals(true, attribute.inheritable); Assert.assertEquals("foo", attribute.value); }
public static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element) { MultiValuedMap<String, SimpleMetaAttribute> result = new HashSetValuedHashMap<String, SimpleMetaAttribute>(); List<Element> metaAttributeList = new ArrayList<Element>(); ArrayList<Element> metaNodes = getChildElements(element, "meta"); for (Element metaNode : metaNodes) { metaAttributeList.add(metaNode); } for (Iterator<Element> iter = metaAttributeList.iterator(); iter.hasNext();) { Element metaAttribute = iter.next(); String attribute = metaAttribute.getAttribute("attribute"); String value = metaAttribute.getTextContent(); String inheritStr= null; if (metaAttribute.hasAttribute("inherit")) { inheritStr = metaAttribute.getAttribute("inherit"); } boolean inherit = true; if(inheritStr!=null) { inherit = Boolean.valueOf(inheritStr).booleanValue(); } SimpleMetaAttribute ma = new SimpleMetaAttribute(value, inherit); result.put(attribute, ma); } return result; }
MetaAttributeHelper { public static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element) { MultiValuedMap<String, SimpleMetaAttribute> result = new HashSetValuedHashMap<String, SimpleMetaAttribute>(); List<Element> metaAttributeList = new ArrayList<Element>(); ArrayList<Element> metaNodes = getChildElements(element, "meta"); for (Element metaNode : metaNodes) { metaAttributeList.add(metaNode); } for (Iterator<Element> iter = metaAttributeList.iterator(); iter.hasNext();) { Element metaAttribute = iter.next(); String attribute = metaAttribute.getAttribute("attribute"); String value = metaAttribute.getTextContent(); String inheritStr= null; if (metaAttribute.hasAttribute("inherit")) { inheritStr = metaAttribute.getAttribute("inherit"); } boolean inherit = true; if(inheritStr!=null) { inherit = Boolean.valueOf(inheritStr).booleanValue(); } SimpleMetaAttribute ma = new SimpleMetaAttribute(value, inherit); result.put(attribute, ma); } return result; } }
MetaAttributeHelper { public static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element) { MultiValuedMap<String, SimpleMetaAttribute> result = new HashSetValuedHashMap<String, SimpleMetaAttribute>(); List<Element> metaAttributeList = new ArrayList<Element>(); ArrayList<Element> metaNodes = getChildElements(element, "meta"); for (Element metaNode : metaNodes) { metaAttributeList.add(metaNode); } for (Iterator<Element> iter = metaAttributeList.iterator(); iter.hasNext();) { Element metaAttribute = iter.next(); String attribute = metaAttribute.getAttribute("attribute"); String value = metaAttribute.getTextContent(); String inheritStr= null; if (metaAttribute.hasAttribute("inherit")) { inheritStr = metaAttribute.getAttribute("inherit"); } boolean inherit = true; if(inheritStr!=null) { inherit = Boolean.valueOf(inheritStr).booleanValue(); } SimpleMetaAttribute ma = new SimpleMetaAttribute(value, inherit); result.put(attribute, ma); } return result; }  }
MetaAttributeHelper { public static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element) { MultiValuedMap<String, SimpleMetaAttribute> result = new HashSetValuedHashMap<String, SimpleMetaAttribute>(); List<Element> metaAttributeList = new ArrayList<Element>(); ArrayList<Element> metaNodes = getChildElements(element, "meta"); for (Element metaNode : metaNodes) { metaAttributeList.add(metaNode); } for (Iterator<Element> iter = metaAttributeList.iterator(); iter.hasNext();) { Element metaAttribute = iter.next(); String attribute = metaAttribute.getAttribute("attribute"); String value = metaAttribute.getTextContent(); String inheritStr= null; if (metaAttribute.hasAttribute("inherit")) { inheritStr = metaAttribute.getAttribute("inherit"); } boolean inherit = true; if(inheritStr!=null) { inherit = Boolean.valueOf(inheritStr).booleanValue(); } SimpleMetaAttribute ma = new SimpleMetaAttribute(value, inherit); result.put(attribute, ma); } return result; }  static MetaAttribute toRealMetaAttribute(String name, Collection<?> values); static MultiValuedMap<String, SimpleMetaAttribute> loadAndMergeMetaMap(
			Element classElement,
			MultiValuedMap<String, SimpleMetaAttribute> inheritedMeta); static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element); }
MetaAttributeHelper { public static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element) { MultiValuedMap<String, SimpleMetaAttribute> result = new HashSetValuedHashMap<String, SimpleMetaAttribute>(); List<Element> metaAttributeList = new ArrayList<Element>(); ArrayList<Element> metaNodes = getChildElements(element, "meta"); for (Element metaNode : metaNodes) { metaAttributeList.add(metaNode); } for (Iterator<Element> iter = metaAttributeList.iterator(); iter.hasNext();) { Element metaAttribute = iter.next(); String attribute = metaAttribute.getAttribute("attribute"); String value = metaAttribute.getTextContent(); String inheritStr= null; if (metaAttribute.hasAttribute("inherit")) { inheritStr = metaAttribute.getAttribute("inherit"); } boolean inherit = true; if(inheritStr!=null) { inherit = Boolean.valueOf(inheritStr).booleanValue(); } SimpleMetaAttribute ma = new SimpleMetaAttribute(value, inherit); result.put(attribute, ma); } return result; }  static MetaAttribute toRealMetaAttribute(String name, Collection<?> values); static MultiValuedMap<String, SimpleMetaAttribute> loadAndMergeMetaMap(
			Element classElement,
			MultiValuedMap<String, SimpleMetaAttribute> inheritedMeta); static MultiValuedMap<String, SimpleMetaAttribute> loadMetaMap(Element element);  }