Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/skills/generate-javadoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Skill: Generate Javadoc

## Purpose
Generate comprehensive Javadocs for public API interfaces and classes in a specified module, following consistent documentation standards.

## Trigger
When the user asks to:
- Generate javadocs for a module
- Add documentation to public APIs
- Document interfaces/classes with `@since` tags

## Requirements

### What to Document
1. **Public API interfaces and classes only** - files in main source packages
2. **Skip implementation classes** - files in `impl/` packages are NOT documented
3. **Skip test classes** - files in `src/test/` are NOT documented

### Javadoc Standards
Each documented element must include:

1. **Class/Interface level:**
- Short description of purpose
- `@param` for type parameters (if generic)
- `@author JavaSaBr`
- `@since 10.0.0`

2. **Method level:**
- Short description for ALL methods
- `@param` and `@return` only for **non-trivial** methods
- `@since 10.0.0`
- `@throws` only when explicitly thrown

3. **Constants/Fields:**
- Short description
- `@since 10.0.0`

### Example Format

```java
/**
* An immutable array interface that provides type-safe, indexed access to elements.
*
* @param <E> the type of elements in this array
* @author JavaSaBr
* @since 10.0.0
*/
public interface Array<E> extends Iterable<E> {

/**
* Creates an empty immutable array of the specified type.
*
* @param <E> the type of elements
* @param type the component type of the array
* @return an empty immutable array
* @since 10.0.0
*/
static <E> Array<E> empty(Class<? super E> type) {
// ...
}

/**
* Returns the number of elements in this array.
*
* @return the number of elements
* @since 10.0.0
*/
int size();

/**
* Returns the element at the specified index.
*
* @param index the index of the element to return
* @return the element at the specified index
* @throws IndexOutOfBoundsException if the index is out of range
* @since 10.0.0
*/
E get(int index);
}
```

## Execution Steps

1. **Analyze module structure:**
```bash
ls -la <module>/src/main/java/<package-path>/
```

2. **Identify public API files:**
- List all `.java` files in main packages
- Exclude `impl/` subdirectories
- Exclude `package-info.java` (optional to document)

3. **Read each file** to understand existing documentation state

4. **Add Javadocs** using `replace_string_in_file` tool:
- Add class-level Javadoc with description, `@author`, `@since`
- Add method-level Javadocs with description and `@since`
- Add `@param`/`@return` only for non-trivial methods

5. **Validate changes:**
```bash
./gradlew :<module>:compileJava
```

6. **Run full build:**
```bash
./gradlew :<module>:build
```

7. **Update summary file** at `./summary.md` with documented files

## Output
- All public API files documented with proper Javadocs
- Build passes successfully
- Summary file updated with documentation status

## Notes
- Use existing code style from the project
- Preserve existing Javadocs that are already complete (just add `@since` if missing)
- Group related edits to minimize tool calls
- Check for errors after editing each file
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package javasabr.rlib.collections.array;

import java.io.Serializable;
Expand Down Expand Up @@ -91,12 +90,12 @@ static LongArray of(long... elements) {
/**
* Creates an immutable copy of the specified long array.
*
* @param intArray the array to copy
* @param array the array to copy
* @return an immutable copy
* @since 10.0.0
*/
static LongArray copyOf(LongArray intArray) {
return new ImmutableLongArray(intArray.toArray());
static LongArray copyOf(LongArray array) {
return new ImmutableLongArray(array.toArray());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface UnsafeMutableIntArray extends UnsafeIntArray, MutableIntArray {
* @return the removed value
* @since 10.0.0
*/
Comment on lines 33 to 35
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsafeRemoveByInex was renamed to unsafeRemoveByIndex, which is a breaking API change for downstream code calling the old method name. Consider keeping a @Deprecated default method named unsafeRemoveByInex(int) that delegates to unsafeRemoveByIndex(int) to preserve source compatibility.

Suggested change
* @return the removed value
* @since 10.0.0
*/
* @return the removed value
* @deprecated use {@link #unsafeRemoveByIndex(int)} instead
* @since 10.0.0
*/
@Deprecated(forRemoval = false, since = "10.0.0")
default int unsafeRemoveByInex(int index) {
return unsafeRemoveByIndex(index);
}
/**
* Removes the element at the specified index without bounds checking.
*
* @param index the index of the element to remove
* @return the removed value
* @since 10.0.0
*/

Copilot uses AI. Check for mistakes.
int unsafeRemoveByInex(int index);
int unsafeRemoveByIndex(int index);

/**
* Sets the value at the specified index without bounds checking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface UnsafeMutableLongArray extends UnsafeLongArray, MutableLongArra
* @return the removed value
* @since 10.0.0
*/
long unsafeRemoveByInex(int index);
long unsafeRemoveByIndex(int index);

/**
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsafeRemoveByInex was renamed to unsafeRemoveByIndex, which is a breaking API change for downstream code calling the old method name. Consider keeping a @Deprecated default method named unsafeRemoveByInex(int) that delegates to unsafeRemoveByIndex(int) to preserve source compatibility.

Suggested change
/**
/**
* @deprecated use {@link #unsafeRemoveByIndex(int)} instead.
*/
@Deprecated
default long unsafeRemoveByInex(int index) {
return unsafeRemoveByIndex(index);
}
/**

Copilot uses AI. Check for mistakes.
* Sets the value at the specified index without bounds checking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean contains(int value) {
@Override
public boolean containsAll(IntArray array) {
if (array.isEmpty()) {
return false;
return true;
}
Comment on lines 62 to 65
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change alters containsAll(...) semantics for empty input to return true (which is likely correct), but there is no test asserting the empty-case behavior. Add a unit test covering containsAll(IntArray.of()) / containsAll(new int[0]) to lock in the intended contract.

Copilot uses AI. Check for mistakes.

int[] wrapped = array.asUnsafe().wrapped();
Expand All @@ -77,7 +77,7 @@ public boolean containsAll(IntArray array) {
@Override
public boolean containsAll(int[] array) {
if (array.length < 1) {
return false;
return true;
}
for (int value : array) {
if (!contains(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean contains(long value) {
@Override
public boolean containsAll(LongArray array) {
if (array.isEmpty()) {
return false;
return true;
}
Comment on lines 62 to 65
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change alters containsAll(...) semantics for empty input to return true (which is likely correct), but there is no test asserting the empty-case behavior. Add a unit test covering containsAll(LongArray.of()) / containsAll(new long[0]) to lock in the intended contract.

Copilot uses AI. Check for mistakes.
long[] wrapped = array.asUnsafe().wrapped();
for (int i = 0, length = array.size(); i < length; i++) {
Expand All @@ -75,7 +75,7 @@ public boolean containsAll(LongArray array) {
@Override
public boolean containsAll(long[] array) {
if (array.length < 1) {
return false;
return true;
}
for (long value : array) {
if (!contains(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public UnsafeMutableIntArray unsafeSet(int index, int value) {
@Override
public int removeByIndex(int index) {
checkIndex(index);
return unsafeRemoveByInex(index);
return unsafeRemoveByIndex(index);
}

@Override
Expand All @@ -75,7 +75,7 @@ public boolean remove(int value) {
if (index < 0) {
return false;
}
unsafeRemoveByInex(index);
unsafeRemoveByIndex(index);
return true;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ public boolean removeAll(int[] array) {
}

@Override
public int unsafeRemoveByInex(int index) {
public int unsafeRemoveByIndex(int index) {
int numMoved = size() - index - 1;
int[] wrapped = wrapped();
int value = wrapped[index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public UnsafeMutableLongArray unsafeSet(int index, long value) {
@Override
public long removeByIndex(int index) {
checkIndex(index);
return unsafeRemoveByInex(index);
return unsafeRemoveByIndex(index);
}

@Override
Expand All @@ -75,7 +75,7 @@ public boolean remove(long value) {
if (index < 0) {
return false;
}
unsafeRemoveByInex(index);
unsafeRemoveByIndex(index);
return true;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ public boolean removeAll(long[] array) {
}

@Override
public long unsafeRemoveByInex(int index) {
public long unsafeRemoveByIndex(int index) {
int numMoved = size() - index - 1;
long[] wrapped = wrapped();
long value = wrapped[index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static <E> Deque<E> linkedListBased() {
* @return a new array based deque
* @since 10.0.0
*/
public static <E> Deque<E> arrayBasedBased(Class<? super E> type) {
public static <E> Deque<E> arrayBased(Class<? super E> type) {
return new DefaultArrayBasedDeque<>(type);
}

Expand All @@ -46,7 +46,7 @@ public static <E> Deque<E> arrayBasedBased(Class<? super E> type) {
* @return a new array based deque
* @since 10.0.0
*/
public static <E> Deque<E> arrayBasedBased(Class<? super E> type, int capacity) {
public static <E> Deque<E> arrayBased(Class<? super E> type, int capacity) {
return new DefaultArrayBasedDeque<>(type, capacity);
Comment on lines 33 to 50
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title/description indicate this is limited to network-module Javadoc updates, but this change renames a public factory method in rlib-collections (and there are other non-network functional/API changes in this PR). Please update the PR description to reflect these additional changes or split them into a separate PR so the scope is clear for reviewers and release notes.

Copilot uses AI. Check for mistakes.
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming arrayBasedBased(...) to arrayBased(...) removes a public API and is a breaking change for downstream callers. If backward compatibility is desired, keep arrayBasedBased(...) as a @Deprecated method that delegates to arrayBased(...) (and similarly for the overload with capacity).

Suggested change
}
}
/**
* Creates a new deque backed by an array.
* <p>
* @deprecated Use {@link #arrayBased(Class)} instead.
*
* @param <E> the type of elements
* @param type the component type of the array
* @return a new array based deque
*/
@Deprecated
public static <E> Deque<E> arrayBasedBased(Class<? super E> type) {
return arrayBased(type);
}
/**
* Creates a new deque backed by an array with initial capacity.
* <p>
* @deprecated Use {@link #arrayBased(Class, int)} instead.
*
* @param <E> the type of elements
* @param type the component type of the array
* @param capacity the initial capacity
* @return a new array based deque
*/
@Deprecated
public static <E> Deque<E> arrayBasedBased(Class<? super E> type, int capacity) {
return arrayBased(type, capacity);
}

Copilot uses AI. Check for mistakes.
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public GcOptimizedMutableHashBasedIntToRefDictionary(int initCapacity, float loa
//noinspection unchecked
this.entries = new ReusableLinkedHashIntToRefEntry[initCapacity];
this.threshold = (int) (initCapacity * loadFactor);
this.entryPool = DequeFactory.arrayBasedBased(ReusableLinkedHashIntToRefEntry.class);
this.entryPool = DequeFactory.arrayBased(ReusableLinkedHashIntToRefEntry.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void shouldCheckContains(Deque<String> deque) {
@Test
void shouldRebalanceIndexesAddLastRemoveFirst() {
// given:
Deque<String> deque = DequeFactory.arrayBasedBased(String.class, 15);
Deque<String> deque = DequeFactory.arrayBased(String.class, 15);
Field head = ReflectionUtils.getUnsafeField(deque, "head");
Field tail = ReflectionUtils.getUnsafeField(deque, "tail");
var generator = new AtomicInteger();
Expand Down Expand Up @@ -541,7 +541,7 @@ void shouldRebalanceIndexesAddLastRemoveFirst() {
@Test
void shouldRebalanceIndexesAddFirstRemoveLast() {
// given:
Deque<String> deque = DequeFactory.arrayBasedBased(String.class, 15);
Deque<String> deque = DequeFactory.arrayBased(String.class, 15);
Field head = ReflectionUtils.getUnsafeField(deque, "head");
Field tail = ReflectionUtils.getUnsafeField(deque, "tail");
var generator = new AtomicInteger();
Expand Down Expand Up @@ -707,6 +707,6 @@ void shouldCorrectlyIterate2Deque(Deque<String> deque) {
private static Stream<Arguments> generateDeque() {
return Stream.of(
Arguments.of(DequeFactory.linkedListBased()),
Arguments.of(DequeFactory.arrayBasedBased(String.class, 15)));
Arguments.of(DequeFactory.arrayBased(String.class, 15)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,79 @@
import java.nio.ByteBuffer;

/**
* The interface to implement a buffer allocator for network things.
* The interface to implement a buffer allocator for network operations.
*
* @author JavaSaBr
* @since 10.0.0
*/
public interface BufferAllocator {

/**
* Get a new read buffer to use.
* Gets a new read buffer to use for receiving data.
*
* @return a read buffer
* @since 10.0.0
*/
ByteBuffer takeReadBuffer();

/**
* Get a new pending buffer to use.
* Gets a new pending buffer to use for storing partial packet data.
*
* @return a pending buffer
* @since 10.0.0
*/
ByteBuffer takePendingBuffer();

/**
* Get a new write buffer to use.
* Gets a new write buffer to use for sending data.
*
* @return a write buffer
* @since 10.0.0
*/
ByteBuffer takeWriteBuffer();

/**
* Get a new buffer with requested capacity.
* Gets a new buffer with the requested capacity.
*
* @param bufferSize the requested buffer size
* @return a buffer with the specified capacity
* @since 10.0.0
*/
ByteBuffer takeBuffer(int bufferSize);

/**
* Store an already used read buffer.
* Stores an already used read buffer for reuse.
*
* @param buffer the read buffer to store
* @return this allocator for method chaining
* @since 10.0.0
*/
BufferAllocator putReadBuffer(ByteBuffer buffer);

/**
* Store an already used pending buffer.
* Stores an already used pending buffer for reuse.
*
* @param buffer the pending buffer to store
* @return this allocator for method chaining
* @since 10.0.0
*/
BufferAllocator putPendingBuffer(ByteBuffer buffer);

/**
* Store an already used write buffer.
* Stores an already used write buffer for reuse.
*
* @param buffer the write buffer to store
* @return this allocator for method chaining
* @since 10.0.0
*/
BufferAllocator putWriteBuffer(ByteBuffer buffer);

/**
* Store an already used byte buffer.
* Stores an already used byte buffer for reuse.
*
* @param buffer the buffer to store
* @return this allocator for method chaining
* @since 10.0.0
*/
BufferAllocator putBuffer(ByteBuffer buffer);
}
Loading
Loading