@Test public void testGetAttribute() { Element element = new Element("id"); String id = "attribute name"; element.setAttribute(id, 0); Assert.assertEquals(0, (int) element.<Integer> getAttribute(id)); Assert.assertNull(element.getAttribute("other")); }
@SuppressWarnings("unchecked") @Override public <O> O getAttribute(String identifier) { if (attributes.getAttributes().containsKey(identifier)) { return (O) attributes.getAttribute(identifier); } else if (parent != null) { return (O) parent.getAttribute(identifier); } else { return null; } }
Element implements IAttributes { @SuppressWarnings("unchecked") @Override public <O> O getAttribute(String identifier) { if (attributes.getAttributes().containsKey(identifier)) { return (O) attributes.getAttribute(identifier); } else if (parent != null) { return (O) parent.getAttribute(identifier); } else { return null; } } }
Element implements IAttributes { @SuppressWarnings("unchecked") @Override public <O> O getAttribute(String identifier) { if (attributes.getAttributes().containsKey(identifier)) { return (O) attributes.getAttribute(identifier); } else if (parent != null) { return (O) parent.getAttribute(identifier); } else { return null; } } Element(String id);  Element(Element parent); }
Element implements IAttributes { @SuppressWarnings("unchecked") @Override public <O> O getAttribute(String identifier) { if (attributes.getAttributes().containsKey(identifier)) { return (O) attributes.getAttribute(identifier); } else if (parent != null) { return (O) parent.getAttribute(identifier); } else { return null; } } Element(String id);  Element(Element parent); String getId(); Element getParent(); void setParent(Element element); @SuppressWarnings("unchecked") @Override O getAttribute(String identifier); @Override boolean isDefined(String identifier); @Override Attributes getAttributes(); Attributes getLocalAttributes(); Set<String> getLocalAttributeNames(); @Override void setAttribute(String identifier, Object object); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override Parameter getAttributeParameter(String identifier); @Override Set<String> getAttributeNames(); String getType(); void setType(String type); }
Element implements IAttributes { @SuppressWarnings("unchecked") @Override public <O> O getAttribute(String identifier) { if (attributes.getAttributes().containsKey(identifier)) { return (O) attributes.getAttribute(identifier); } else if (parent != null) { return (O) parent.getAttribute(identifier); } else { return null; } } Element(String id);  Element(Element parent); String getId(); Element getParent(); void setParent(Element element); @SuppressWarnings("unchecked") @Override O getAttribute(String identifier); @Override boolean isDefined(String identifier); @Override Attributes getAttributes(); Attributes getLocalAttributes(); Set<String> getLocalAttributeNames(); @Override void setAttribute(String identifier, Object object); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override Parameter getAttributeParameter(String identifier); @Override Set<String> getAttributeNames(); String getType(); void setType(String type); static String TYPE; }