RecyclableArrayList Class — netty Architecture
Architecture documentation for the RecyclableArrayList class in RecyclableArrayList.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD eed483d0_fa64_c9fe_feea_50c5f374e56e["RecyclableArrayList"] cd17e3cf_851f_441b_bebb_818e78512be8["RecyclableArrayList.java"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|defined in| cd17e3cf_851f_441b_bebb_818e78512be8 286a0b34_6839_e142_ed08_08feeb40d36c["RecyclableArrayList()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| 286a0b34_6839_e142_ed08_08feeb40d36c 313f3759_cb22_a87d_0558_f4b07f7568dd["addAll()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| 313f3759_cb22_a87d_0558_f4b07f7568dd 2d57f94f_580b_bff8_c67b_4d5eaf41655f["checkNullElements()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| 2d57f94f_580b_bff8_c67b_4d5eaf41655f ebee78d2_b30e_caa7_115a_6152d57a3051["add()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| ebee78d2_b30e_caa7_115a_6152d57a3051 9362937a_ce15_90d5_4f7f_9eabb4737833["Object()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| 9362937a_ce15_90d5_4f7f_9eabb4737833 57d03ed7_9bb2_5db1_2fb7_b60a1f880db4["insertSinceRecycled()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| 57d03ed7_9bb2_5db1_2fb7_b60a1f880db4 be084e0b_0f63_f9ee_fd1c_7fdd1392b6e5["recycle()"] eed483d0_fa64_c9fe_feea_50c5f374e56e -->|method| be084e0b_0f63_f9ee_fd1c_7fdd1392b6e5
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/RecyclableArrayList.java lines 30–150
public final class RecyclableArrayList extends ArrayList<Object> {
private static final long serialVersionUID = -8605125654176467947L;
private static final int DEFAULT_INITIAL_CAPACITY = 8;
private static final Recycler<RecyclableArrayList> RECYCLER =
new Recycler<RecyclableArrayList>() {
@Override
protected RecyclableArrayList newObject(Handle<RecyclableArrayList> handle) {
return new RecyclableArrayList(handle);
}
};
private boolean insertSinceRecycled;
/**
* Create a new empty {@link RecyclableArrayList} instance
*/
public static RecyclableArrayList newInstance() {
return newInstance(DEFAULT_INITIAL_CAPACITY);
}
/**
* Create a new empty {@link RecyclableArrayList} instance with the given capacity.
*/
public static RecyclableArrayList newInstance(int minCapacity) {
RecyclableArrayList ret = RECYCLER.get();
ret.ensureCapacity(minCapacity);
return ret;
}
private final Handle<RecyclableArrayList> handle;
private RecyclableArrayList(Handle<RecyclableArrayList> handle) {
this(handle, DEFAULT_INITIAL_CAPACITY);
}
private RecyclableArrayList(Handle<RecyclableArrayList> handle, int initialCapacity) {
super(initialCapacity);
this.handle = handle;
}
@Override
public boolean addAll(Collection<?> c) {
checkNullElements(c);
if (super.addAll(c)) {
insertSinceRecycled = true;
return true;
}
return false;
}
@Override
public boolean addAll(int index, Collection<?> c) {
checkNullElements(c);
if (super.addAll(index, c)) {
insertSinceRecycled = true;
return true;
}
return false;
}
private static void checkNullElements(Collection<?> c) {
if (c instanceof RandomAccess && c instanceof List) {
// produce less garbage
List<?> list = (List<?>) c;
int size = list.size();
for (int i = 0; i < size; i++) {
if (list.get(i) == null) {
throw new IllegalArgumentException("c contains null values");
}
}
} else {
for (Object element: c) {
if (element == null) {
throw new IllegalArgumentException("c contains null values");
}
}
}
}
Source
Frequently Asked Questions
What is the RecyclableArrayList class?
RecyclableArrayList is a class in the netty codebase, defined in common/src/main/java/io/netty/util/internal/RecyclableArrayList.java.
Where is RecyclableArrayList defined?
RecyclableArrayList is defined in common/src/main/java/io/netty/util/internal/RecyclableArrayList.java at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free