AbstractAttributeProvider implements AttributeProvider, Iterable<Attribute> { @Pure @Override public boolean getAttribute(String name, boolean defaultValue) { final AttributeValue value = getAttribute(name); if (value != null) { try { return value.getBoolean(); } catch (AttributeException exception) { } } return defaultValue; }  @Pure @Override Iterator<Attribute> iterator(); @Pure @Override AttributeProvider clone(); @Pure @Override Iterable<Attribute> attributes(); @Pure @Override boolean getAttributeAsBool(String name); @Pure @Override int getAttributeAsInt(String name); @Pure @Override long getAttributeAsLong(String name); @Pure @Override float getAttributeAsFloat(String name); @Pure @Override double getAttributeAsDouble(String name); @Pure @Override String getAttributeAsString(String name); @Pure @Override UUID getAttributeAsUUID(String name); @Pure @Override URL getAttributeAsURL(String name); @Pure @Override URI getAttributeAsURI(String name); @Pure @Override Date getAttributeAsDate(String name); @Pure @Override InetAddress getAttributeAsInetAddress(String name); @Pure @Override Enum<?> getAttributeAsEnumeration(String name); @Pure @Override T getAttributeAsEnumeration(String name, Class<T> type); @Pure @Override Class<?> getAttributeAsJavaClass(String name); @Pure @Override boolean getAttribute(String name, boolean defaultValue); @Pure @Override int getAttribute(String name, int defaultValue); @Pure @Override long getAttribute(String name, long defaultValue); @Pure @Override float getAttribute(String name, float defaultValue); @Pure @Override double getAttribute(String name, double defaultValue); @Pure @Override String getAttribute(String name, String defaultValue); @Pure @Override UUID getAttribute(String name, UUID defaultValue); @Pure @Override URL getAttribute(String name, URL defaultValue); @Pure @Override URI getAttribute(String name, URI defaultValue); @Pure @Override Date getAttribute(String name, Date defaultValue); @Pure @Override InetAddress getAttribute(String name, InetAddress defaultValue); @Pure @Override InetAddress getAttribute(String name, InetSocketAddress defaultValue); @Pure @Override @SuppressWarnings("unchecked") T getAttribute(String name, T defaultValue); @Pure @Override Class<?> getAttribute(String name, Class<?> defaultValue); @Override final String toString(); @Override void toJson(JsonBuffer buffer);  }
@Test public void getAttributeString() { assertEquals(this.baseData[0],this.testData.getAttribute("A")); assertNull(this.testData.getAttribute("X")); assertEquals(this.baseData[1],this.testData.getAttribute("B")); assertNull(this.testData.getAttribute("Y")); assertEquals(this.baseData[2],this.testData.getAttribute("C")); assertNull(this.testData.getAttribute("Z")); assertEquals(this.baseData[3],this.testData.getAttribute("D")); assertNull(this.testData.getAttribute("W")); assertEquals(this.baseData[4],this.testData.getAttribute("E")); assertEquals(this.baseData[5],this.testData.getAttribute("F")); }
@Test public void getAttributeStringAttributeValue() { AttributeValue defaultValue = new AttributeValueImpl(); assertEquals(this.baseData[0],this.testData.getAttribute("A",defaultValue)); assertSame(defaultValue, this.testData.getAttribute("X", defaultValue)); assertEquals(this.baseData[1],this.testData.getAttribute("B", defaultValue)); assertSame(defaultValue, this.testData.getAttribute("Y", defaultValue)); assertEquals(this.baseData[2],this.testData.getAttribute("C", defaultValue)); assertSame(defaultValue, this.testData.getAttribute("Z", defaultValue)); assertEquals(this.baseData[3],this.testData.getAttribute("D", defaultValue)); assertSame(defaultValue, this.testData.getAttribute("W", defaultValue)); assertEquals(this.baseData[4],this.testData.getAttribute("E", defaultValue)); assertEquals(this.baseData[5],this.testData.getAttribute("F", defaultValue)); }
@Test public void getAttributeObject() { assertEquals(this.baseData[0],this.testData.getAttributeObject("A")); assertNull(this.testData.getAttribute("X")); assertEquals(this.baseData[1],this.testData.getAttributeObject("B")); assertNull(this.testData.getAttribute("Y")); assertEquals(this.baseData[2],this.testData.getAttributeObject("C")); assertNull(this.testData.getAttribute("Z")); assertEquals(this.baseData[3],this.testData.getAttributeObject("D")); assertNull(this.testData.getAttribute("W")); assertEquals(this.baseData[4],this.testData.getAttributeObject("E")); assertEquals(this.baseData[5],this.testData.getAttributeObject("F")); }
@Test public void getAttributeStringBoolean() throws Exception { assertTrue(this.testData.getAttribute("A",true)); assertTrue(this.testData.getAttribute("B",false)); assertTrue(this.testData.getAttribute("C",false)); assertTrue(this.testData.getAttribute("D",true)); assertFalse(this.testData.getAttribute("E",false)); assertFalse(this.testData.getAttribute("F",true)); }
@Test public void getAttributeStringInt() throws Exception { assertEquals(1,this.testData.getAttribute("A",5)); assertEquals(2,this.testData.getAttribute("B",34)); assertEquals(1,this.testData.getAttribute("C",18)); assertEquals(24,this.testData.getAttribute("D",24)); assertEquals(-34,this.testData.getAttribute("E",-34)); assertEquals(18,this.testData.getAttribute("F",18)); }
@Test public void getAttributegStringLong() throws Exception { assertEquals(1,this.testData.getAttribute("A",5)); assertEquals(2,this.testData.getAttribute("B",34)); assertEquals(1,this.testData.getAttribute("C",18)); assertEquals(24,this.testData.getAttribute("D",24)); assertEquals(-34,this.testData.getAttribute("E",-34)); assertEquals(18,this.testData.getAttribute("F",18)); }
@Test public void getAttributeStringFloat() throws Exception { assertEpsilonEquals(1f,this.testData.getAttribute("A",5f)); assertEpsilonEquals(2f,this.testData.getAttribute("B",34f)); assertEpsilonEquals(1f,this.testData.getAttribute("C",18f)); assertEpsilonEquals(24f,this.testData.getAttribute("D",24f)); assertEpsilonEquals(-34f,this.testData.getAttribute("E",-34f)); assertEpsilonEquals(18f,this.testData.getAttribute("F",18f)); }
@Test public void getAttributeStringDouble() throws Exception { assertEpsilonEquals(1.,this.testData.getAttribute("A",5.)); assertEpsilonEquals(2.,this.testData.getAttribute("B",34.)); assertEpsilonEquals(1.,this.testData.getAttribute("C",18.)); assertEpsilonEquals(24.,this.testData.getAttribute("D",24.)); assertEpsilonEquals(-34.,this.testData.getAttribute("E",-34.)); assertEpsilonEquals(18.,this.testData.getAttribute("F",18.)); }