Skip to content

Conversation

@JavaSaBr
Copy link
Owner

Extend library API part 9

@JavaSaBr JavaSaBr self-assigned this Jan 17, 2026
Copilot AI review requested due to automatic review settings January 17, 2026 16:40
@github-actions
Copy link

Overall Project 48.53% -0.12% 🍏
Files changed 82.01% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.5% -1.48% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request extends the RLib library API with new utility methods for string operations, enum alias resolution, and array sorting capabilities. The changes include version bumping from 10.0.alpha9 to 10.0.alpha10.

Changes:

  • Added AliasedEnum interface and AliasedEnumMap utility for resolving enum constants by string aliases
  • Extended StringUtils with blank checking methods (isBlank, isNotBlank, ifBlank) complementing existing empty checking methods
  • Added sort functionality to MutableArray interface with implementations for natural ordering and custom comparators
  • Bumped library version to 10.0.alpha10 in build configuration and README

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
rlib-common/src/main/java/javasabr/rlib/common/AliasedEnum.java New interface for enums with string aliases
rlib-common/src/main/java/javasabr/rlib/common/util/AliasedEnumMap.java New utility class to resolve enum constants by aliases with validation
rlib-common/src/test/java/javasabr/rlib/common/util/AliasedEnumMapTest.java Test coverage for AliasedEnumMap functionality
rlib-common/src/main/java/javasabr/rlib/common/util/StringUtils.java Added blank checking methods and updated documentation
rlib-common/src/test/java/javasabr/rlib/common/util/StringUtilsTest.java Test coverage for new string utility methods
rlib-collections/src/main/java/javasabr/rlib/collections/array/MutableArray.java Added sort method declarations to interface
rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/AbstractMutableArray.java Implemented sort methods with natural order and custom comparator support
rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/CopyOnWriteMutableArray.java Thread-safe sort implementation using copy-on-write strategy
rlib-collections/src/test/java/javasabr/rlib/collections/array/MutableArrayTest.java Test coverage for array sorting functionality
build.gradle Version bump to 10.0.alpha10
README.md Version reference update to 10.0.alpha10

Comment on lines 13 to 51
public class AliasedEnumMap<T extends Enum<T> & AliasedEnum<T>> {

Map<String, T> aliasToValue;

public AliasedEnumMap(Class<T> enumClass) {
var enumConstants = enumClass.getEnumConstants();
var aliasToValue = new HashMap<String, T>();

for (T enumConstant : enumConstants) {
for (String alias : enumConstant.aliases()) {
T previous = aliasToValue.put(alias, enumConstant);
if (previous != null) {
throw new IllegalArgumentException("Detect duplicated alias:[%s] for [%s] and [%s]".formatted(
alias,
previous.name(),
enumConstant.name()));
}
}
}
this.aliasToValue = Map.copyOf(aliasToValue);
}

@Nullable
public T resolve(String alias) {
return aliasToValue.get(alias);
}

public T resolve(String alias, T def) {
T resolved = resolve(alias);
return resolved == null ? def : resolved;
}

public T require(String alias) {
T constant = resolve(alias);
if (constant == null) {
throw new IllegalArgumentException("Unknown enum constant for alias:[%s]".formatted(alias));
}
return constant;
}
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

Missing documentation for public API. This new class should have a class-level Javadoc comment explaining its purpose and usage, and each public method (constructor, resolve, require) should be documented with parameter descriptions, return value descriptions, and any exceptions that may be thrown (e.g., IllegalArgumentException for duplicate aliases in constructor, or for unknown aliases in require()).

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +54

void sort();

Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

Missing documentation for public API methods. The newly added sort methods should have Javadoc comments describing their behavior, parameters, and any exceptions they might throw. For example, the sort() method should document that it sorts elements in their natural order (if Comparable) or by hashcode, and that ConcurrentModificationException might be thrown in concurrent contexts.

Suggested change
void sort();
/**
* Sorts the elements of this array in-place.
* <p>
* If the elements implement {@link Comparable}, they are sorted according to their natural
* order. Otherwise, elements are ordered by their {@link Object#hashCode()} values.
*
* @throws java.lang.ClassCastException if the elements are not mutually comparable when
* natural ordering is used
* @throws java.util.ConcurrentModificationException if the array is structurally modified
* while the sort is in progress
*/
void sort();
/**
* Sorts the elements of this array in-place using the provided comparator.
*
* @param comparator the comparator to determine the order of the elements; must not be
* {@code null}
*
* @throws java.util.ConcurrentModificationException if the array is structurally modified
* while the sort is in progress
*/

Copilot uses AI. Check for mistakes.
mutableArray.addAll(Array.of("10", "99", "5", "3", "77", "45", "25", "56"));

// when:
mutableArray.sort(Comparator.comparingInt(Integer::parseInt));
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

Potential uncaught 'java.lang.NumberFormatException'.

Suggested change
mutableArray.sort(Comparator.comparingInt(Integer::parseInt));
mutableArray.sort(Comparator.comparingInt(value -> {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Non-numeric value in array: " + value, e);
}
}));

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Overall Project 48.52% -0.12% 🍏
Files changed 82.01% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.5% -1.48% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

@github-actions
Copy link

Overall Project 48.5% -0.12% 🍏
Files changed 82.35% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.7% -1.23% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

@github-actions
Copy link

Overall Project 48.5% -0.12% 🍏
Files changed 82.35% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.7% -1.23% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

@github-actions
Copy link

Overall Project 48.5% -0.12% 🍏
Files changed 82.35% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.7% -1.23% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

@github-actions
Copy link

Overall Project 48.5% -0.12% 🍏
Files changed 82.35% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.7% -1.23% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

@JavaSaBr JavaSaBr merged commit 933234f into develop Jan 17, 2026
6 checks passed
@JavaSaBr JavaSaBr deleted the extend-api-v9 branch January 17, 2026 16:52
@github-actions
Copy link

Overall Project 48.53% -0.12% 🍏
Files changed 82.35% 🍏

File Coverage
StringUtils.java 83.75% 🍏
AbstractMutableArray.java 83.7% -1.23% 🍏
CopyOnWriteMutableArray.java 81.32% -3.19% 🍏
AliasedEnumMap.java 79.82% -20.18% 🍏
MutableArray.java 45% 🍏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants