Home / Function/ attr() — netty Function Reference

attr() — netty Function Reference

Architecture documentation for the attr() function in DefaultAttributeMap.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  c7821402_c1b3_d927_bcbd_43fa921be527["attr()"]
  bbb6a8bc_5354_cb1a_513e_c44f549e2d8f["DefaultAttributeMap"]
  c7821402_c1b3_d927_bcbd_43fa921be527 -->|defined in| bbb6a8bc_5354_cb1a_513e_c44f549e2d8f
  29dc4ae3_4501_cdff_abe5_6eb56b31bc3b["searchAttributeByKey()"]
  c7821402_c1b3_d927_bcbd_43fa921be527 -->|calls| 29dc4ae3_4501_cdff_abe5_6eb56b31bc3b
  08b08571_4145_df8d_c6bf_147379e2e4cd["key()"]
  c7821402_c1b3_d927_bcbd_43fa921be527 -->|calls| 08b08571_4145_df8d_c6bf_147379e2e4cd
  df51fb47_9165_8cd5_37d9_8d9fbf328c27["isRemoved()"]
  c7821402_c1b3_d927_bcbd_43fa921be527 -->|calls| df51fb47_9165_8cd5_37d9_8d9fbf328c27
  06e2906f_6470_6af3_c0b4_8b62aa0c0e87["orderedCopyOnInsert()"]
  c7821402_c1b3_d927_bcbd_43fa921be527 -->|calls| 06e2906f_6470_6af3_c0b4_8b62aa0c0e87
  style c7821402_c1b3_d927_bcbd_43fa921be527 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/DefaultAttributeMap.java lines 86–120

    @SuppressWarnings("unchecked")
    @Override
    public <T> Attribute<T> attr(AttributeKey<T> key) {
        ObjectUtil.checkNotNull(key, "key");
        DefaultAttribute newAttribute = null;
        for (;;) {
            final DefaultAttribute[] attributes = this.attributes;
            final int index = searchAttributeByKey(attributes, key);
            final DefaultAttribute[] newAttributes;
            if (index >= 0) {
                final DefaultAttribute attribute = attributes[index];
                assert attribute.key() == key;
                if (!attribute.isRemoved()) {
                    return attribute;
                }
                // let's try replace the removed attribute with a new one
                if (newAttribute == null) {
                    newAttribute = new DefaultAttribute<T>(this, key);
                }
                final int count = attributes.length;
                newAttributes = Arrays.copyOf(attributes, count);
                newAttributes[index] = newAttribute;
            } else {
                if (newAttribute == null) {
                    newAttribute = new DefaultAttribute<T>(this, key);
                }
                final int count = attributes.length;
                newAttributes = new DefaultAttribute[count + 1];
                orderedCopyOnInsert(attributes, count, newAttributes, newAttribute);
            }
            if (ATTRIBUTES_UPDATER.compareAndSet(this, attributes, newAttributes)) {
                return newAttribute;
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does attr() do?
attr() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/DefaultAttributeMap.java.
Where is attr() defined?
attr() is defined in common/src/main/java/io/netty/util/DefaultAttributeMap.java at line 86.
What does attr() call?
attr() calls 4 function(s): isRemoved, key, orderedCopyOnInsert, searchAttributeByKey.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free