Skip to content

Commit 043d6ab

Browse files
authored
Update javadoc for network module. (#60)
1 parent 30e1ca5 commit 043d6ab

39 files changed

+912
-173
lines changed

.github/skills/generate-javadoc.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Skill: Generate Javadoc
2+
3+
## Purpose
4+
Generate comprehensive Javadocs for public API interfaces and classes in a specified module, following consistent documentation standards.
5+
6+
## Trigger
7+
When the user asks to:
8+
- Generate javadocs for a module
9+
- Add documentation to public APIs
10+
- Document interfaces/classes with `@since` tags
11+
12+
## Requirements
13+
14+
### What to Document
15+
1. **Public API interfaces and classes only** - files in main source packages
16+
2. **Skip implementation classes** - files in `impl/` packages are NOT documented
17+
3. **Skip test classes** - files in `src/test/` are NOT documented
18+
19+
### Javadoc Standards
20+
Each documented element must include:
21+
22+
1. **Class/Interface level:**
23+
- Short description of purpose
24+
- `@param` for type parameters (if generic)
25+
- `@author JavaSaBr`
26+
- `@since 10.0.0`
27+
28+
2. **Method level:**
29+
- Short description for ALL methods
30+
- `@param` and `@return` only for **non-trivial** methods
31+
- `@since 10.0.0`
32+
- `@throws` only when explicitly thrown
33+
34+
3. **Constants/Fields:**
35+
- Short description
36+
- `@since 10.0.0`
37+
38+
### Example Format
39+
40+
```java
41+
/**
42+
* An immutable array interface that provides type-safe, indexed access to elements.
43+
*
44+
* @param <E> the type of elements in this array
45+
* @author JavaSaBr
46+
* @since 10.0.0
47+
*/
48+
public interface Array<E> extends Iterable<E> {
49+
50+
/**
51+
* Creates an empty immutable array of the specified type.
52+
*
53+
* @param <E> the type of elements
54+
* @param type the component type of the array
55+
* @return an empty immutable array
56+
* @since 10.0.0
57+
*/
58+
static <E> Array<E> empty(Class<? super E> type) {
59+
// ...
60+
}
61+
62+
/**
63+
* Returns the number of elements in this array.
64+
*
65+
* @return the number of elements
66+
* @since 10.0.0
67+
*/
68+
int size();
69+
70+
/**
71+
* Returns the element at the specified index.
72+
*
73+
* @param index the index of the element to return
74+
* @return the element at the specified index
75+
* @throws IndexOutOfBoundsException if the index is out of range
76+
* @since 10.0.0
77+
*/
78+
E get(int index);
79+
}
80+
```
81+
82+
## Execution Steps
83+
84+
1. **Analyze module structure:**
85+
```bash
86+
ls -la <module>/src/main/java/<package-path>/
87+
```
88+
89+
2. **Identify public API files:**
90+
- List all `.java` files in main packages
91+
- Exclude `impl/` subdirectories
92+
- Exclude `package-info.java` (optional to document)
93+
94+
3. **Read each file** to understand existing documentation state
95+
96+
4. **Add Javadocs** using `replace_string_in_file` tool:
97+
- Add class-level Javadoc with description, `@author`, `@since`
98+
- Add method-level Javadocs with description and `@since`
99+
- Add `@param`/`@return` only for non-trivial methods
100+
101+
5. **Validate changes:**
102+
```bash
103+
./gradlew :<module>:compileJava
104+
```
105+
106+
6. **Run full build:**
107+
```bash
108+
./gradlew :<module>:build
109+
```
110+
111+
7. **Update summary file** at `./summary.md` with documented files
112+
113+
## Output
114+
- All public API files documented with proper Javadocs
115+
- Build passes successfully
116+
- Summary file updated with documentation status
117+
118+
## Notes
119+
- Use existing code style from the project
120+
- Preserve existing Javadocs that are already complete (just add `@since` if missing)
121+
- Group related edits to minimize tool calls
122+
- Check for errors after editing each file

rlib-collections/src/main/java/javasabr/rlib/collections/array/LongArray.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
package javasabr.rlib.collections.array;
32

43
import java.io.Serializable;
@@ -91,12 +90,12 @@ static LongArray of(long... elements) {
9190
/**
9291
* Creates an immutable copy of the specified long array.
9392
*
94-
* @param intArray the array to copy
93+
* @param array the array to copy
9594
* @return an immutable copy
9695
* @since 10.0.0
9796
*/
98-
static LongArray copyOf(LongArray intArray) {
99-
return new ImmutableLongArray(intArray.toArray());
97+
static LongArray copyOf(LongArray array) {
98+
return new ImmutableLongArray(array.toArray());
10099
}
101100

102101
/**

rlib-collections/src/main/java/javasabr/rlib/collections/array/UnsafeMutableIntArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface UnsafeMutableIntArray extends UnsafeIntArray, MutableIntArray {
3333
* @return the removed value
3434
* @since 10.0.0
3535
*/
36-
int unsafeRemoveByInex(int index);
36+
int unsafeRemoveByIndex(int index);
3737

3838
/**
3939
* Sets the value at the specified index without bounds checking.

rlib-collections/src/main/java/javasabr/rlib/collections/array/UnsafeMutableLongArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface UnsafeMutableLongArray extends UnsafeLongArray, MutableLongArra
3333
* @return the removed value
3434
* @since 10.0.0
3535
*/
36-
long unsafeRemoveByInex(int index);
36+
long unsafeRemoveByIndex(int index);
3737

3838
/**
3939
* Sets the value at the specified index without bounds checking.

rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/AbstractIntArray.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public boolean contains(int value) {
6161
@Override
6262
public boolean containsAll(IntArray array) {
6363
if (array.isEmpty()) {
64-
return false;
64+
return true;
6565
}
6666

6767
int[] wrapped = array.asUnsafe().wrapped();
@@ -77,7 +77,7 @@ public boolean containsAll(IntArray array) {
7777
@Override
7878
public boolean containsAll(int[] array) {
7979
if (array.length < 1) {
80-
return false;
80+
return true;
8181
}
8282
for (int value : array) {
8383
if (!contains(value)) {

rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/AbstractLongArray.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public boolean contains(long value) {
6161
@Override
6262
public boolean containsAll(LongArray array) {
6363
if (array.isEmpty()) {
64-
return false;
64+
return true;
6565
}
6666
long[] wrapped = array.asUnsafe().wrapped();
6767
for (int i = 0, length = array.size(); i < length; i++) {
@@ -75,7 +75,7 @@ public boolean containsAll(LongArray array) {
7575
@Override
7676
public boolean containsAll(long[] array) {
7777
if (array.length < 1) {
78-
return false;
78+
return true;
7979
}
8080
for (long value : array) {
8181
if (!contains(value)) {

rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/AbstractMutableIntArray.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public UnsafeMutableIntArray unsafeSet(int index, int value) {
6666
@Override
6767
public int removeByIndex(int index) {
6868
checkIndex(index);
69-
return unsafeRemoveByInex(index);
69+
return unsafeRemoveByIndex(index);
7070
}
7171

7272
@Override
@@ -75,7 +75,7 @@ public boolean remove(int value) {
7575
if (index < 0) {
7676
return false;
7777
}
78-
unsafeRemoveByInex(index);
78+
unsafeRemoveByIndex(index);
7979
return true;
8080
}
8181

@@ -108,7 +108,7 @@ public boolean removeAll(int[] array) {
108108
}
109109

110110
@Override
111-
public int unsafeRemoveByInex(int index) {
111+
public int unsafeRemoveByIndex(int index) {
112112
int numMoved = size() - index - 1;
113113
int[] wrapped = wrapped();
114114
int value = wrapped[index];

rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/AbstractMutableLongArray.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public UnsafeMutableLongArray unsafeSet(int index, long value) {
6666
@Override
6767
public long removeByIndex(int index) {
6868
checkIndex(index);
69-
return unsafeRemoveByInex(index);
69+
return unsafeRemoveByIndex(index);
7070
}
7171

7272
@Override
@@ -75,7 +75,7 @@ public boolean remove(long value) {
7575
if (index < 0) {
7676
return false;
7777
}
78-
unsafeRemoveByInex(index);
78+
unsafeRemoveByIndex(index);
7979
return true;
8080
}
8181

@@ -108,7 +108,7 @@ public boolean removeAll(long[] array) {
108108
}
109109

110110
@Override
111-
public long unsafeRemoveByInex(int index) {
111+
public long unsafeRemoveByIndex(int index) {
112112
int numMoved = size() - index - 1;
113113
long[] wrapped = wrapped();
114114
long value = wrapped[index];

rlib-collections/src/main/java/javasabr/rlib/collections/deque/DequeFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static <E> Deque<E> linkedListBased() {
3333
* @return a new array based deque
3434
* @since 10.0.0
3535
*/
36-
public static <E> Deque<E> arrayBasedBased(Class<? super E> type) {
36+
public static <E> Deque<E> arrayBased(Class<? super E> type) {
3737
return new DefaultArrayBasedDeque<>(type);
3838
}
3939

@@ -46,7 +46,7 @@ public static <E> Deque<E> arrayBasedBased(Class<? super E> type) {
4646
* @return a new array based deque
4747
* @since 10.0.0
4848
*/
49-
public static <E> Deque<E> arrayBasedBased(Class<? super E> type, int capacity) {
49+
public static <E> Deque<E> arrayBased(Class<? super E> type, int capacity) {
5050
return new DefaultArrayBasedDeque<>(type, capacity);
5151
}
5252
}

rlib-collections/src/main/java/javasabr/rlib/collections/dictionary/impl/gc/optimized/GcOptimizedMutableHashBasedIntToRefDictionary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public GcOptimizedMutableHashBasedIntToRefDictionary(int initCapacity, float loa
3434
//noinspection unchecked
3535
this.entries = new ReusableLinkedHashIntToRefEntry[initCapacity];
3636
this.threshold = (int) (initCapacity * loadFactor);
37-
this.entryPool = DequeFactory.arrayBasedBased(ReusableLinkedHashIntToRefEntry.class);
37+
this.entryPool = DequeFactory.arrayBased(ReusableLinkedHashIntToRefEntry.class);
3838
}
3939

4040
@Override

0 commit comments

Comments
 (0)