List of usage examples for io.netty.util Attribute key
AttributeKey<T> key();
From source file:com.linecorp.armeria.common.logging.DefaultResponseLog.java
License:Apache License
@Override boolean includeAttr(Attribute<?> attr) { return attr.key() != RAW_RPC_RESPONSE; }
From source file:com.linecorp.armeria.internal.DefaultAttributeMap.java
License:Apache License
@Override public String toString() { final ToStringHelper helper = MoreObjects.toStringHelper(""); for (Iterator<Attribute<?>> i = attrs(); i.hasNext();) { final Attribute<?> a = i.next(); helper.add(a.key().name(), a.get()); }//w ww.j a v a2s .c o m return helper.toString(); }
From source file:com.linecorp.armeria.internal.DefaultAttributeMapTest.java
License:Apache License
@Test public void testIteratorWithFullMap() { final List<AttributeKey<Integer>> expectedKeys = new ArrayList<>(); for (int i = 0; i < 1024; i++) { final AttributeKey<Integer> key = AttributeKey.valueOf(DefaultAttributeMapTest.class, String.valueOf(i)); expectedKeys.add(key);// w w w. j a v a2s. c om map.attr(key).set(i); } // Make sure all buckets are filled. for (int i = 0; i < map.attributes.length(); i++) { assertNotNull(map.attributes.get(i)); } // Make sure the Iterator yields all attributes. assertEquals(expectedKeys, actualKeys()); // Make sure the Iterator does not yield the attributes whose 'removed' property is 'true'. for (int i = 0; i < map.attributes.length(); i++) { Attribute<?> a = map.attributes.get(i); a.remove(); // A head attribute is never removed from the linked list. assertSame(a, map.attributes.get(i)); // Remove the removed key from the list of expected expectedKeys. expectedKeys.remove(a.key()); } assertEquals(expectedKeys, actualKeys()); }