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
216 changes: 216 additions & 0 deletions JavaSabr-codestyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
<code_scheme name="JavaSabr" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<option name="SOFT_MARGINS" value="100" />
<JavaCodeStyleSettings>
<option name="VISIBILITY" value="private" />
<option name="REPLACE_INSTANCEOF_AND_CAST" value="true" />
<option name="ANNOTATION_PARAMETER_WRAP" value="5" />
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" module="true" />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
</value>
</option>
<option name="RECORD_COMPONENTS_WRAP" value="5" />
<option name="NEW_LINE_AFTER_LPAREN_IN_RECORD_HEADER" value="true" />
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
<REPEAT_ANNOTATIONS>
<ANNO name="org.jspecify.annotations.NonNull" />
<ANNO name="org.jspecify.annotations.Nullable" />
<ANNO name="org.junit.jupiter.api.AfterEach" />
<ANNO name="org.junit.jupiter.api.BeforeEach" />
</REPEAT_ANNOTATIONS>
</JavaCodeStyleSettings>
<TypeScriptCodeStyleSettings version="0">
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
</TypeScriptCodeStyleSettings>
<editorconfig>
<option name="ENABLED" value="false" />
</editorconfig>
<codeStyleSettings language="Groovy">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="LABEL_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="HTML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BETWEEN_PACKAGE_DECLARATION_AND_HEADER" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="5" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="2" />
<option name="WRAP_FIRST_METHOD_IN_CALL_CHAIN" value="true" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="2" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<option name="WRAP_COMMENTS" value="true" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="WRAP_LONG_LINES" value="true" />
<option name="PARAMETER_ANNOTATION_WRAP" value="5" />
<option name="ENUM_CONSTANTS_WRAP" value="2" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<FINAL>true</FINAL>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<FIELD>true</FIELD>
<STATIC>true</STATIC>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
<STATIC>true</STATIC>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<METHOD>true</METHOD>
<STATIC>true</STATIC>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<FIELD>true</FIELD>
</match>
</rule>
</section>
<section>
<rule>
<match>
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
</match>
</rule>
</section>
<section>
<rule>
<match>
<CONSTRUCTOR>true</CONSTRUCTOR>
</match>
</rule>
</section>
<section>
<rule>
<match>
<METHOD>true</METHOD>
</match>
</rule>
</section>
<section>
<rule>
<match>
<ENUM>true</ENUM>
</match>
</rule>
</section>
<section>
<rule>
<match>
<INTERFACE>true</INTERFACE>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<CLASS>true</CLASS>
<STATIC>true</STATIC>
</AND>
</match>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="JSON">
<option name="WRAP_ON_TYPING" value="0" />
</codeStyleSettings>
<codeStyleSettings language="JavaScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="TypeScript">
<option name="RIGHT_MARGIN" value="140" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
</codeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ ext {
}

dependencies {
implementation "javasabr:rlib-common:$rlibVersion"
implementation "javasabr:rlib-collections:$rlibVersion"
implementation "javasabr:rlib-compiler:$rlibVersion"
implementation "javasabr:rlib-concurrent:$rlibVersion"
implementation "javasabr:rlib-geometry:$rlibVersion"
implementation "javasabr:rlib-logger-api:$rlibVersion"
implementation "javasabr:rlib-logger-slf4j:$rlibVersion"
implementation "javasabr:rlib-plugin-system:$rlibVersion"
implementation "javasabr:rlib-reference:$rlibVersion"
implementation "javasabr:rlib-reusable:$rlibVersion"
implementation "javasabr:rlib-fx:$rlibVersion"
implementation "javasabr:rlib-network:$rlibVersion"
implementation "javasabr:rlib-mail:$rlibVersion"
implementation "javasabr:rlib-testcontainers:$rlibVersion"
implementation "javasabr.rlib:rlib-common:$rlibVersion"
implementation "javasabr.rlib:rlib-collections:$rlibVersion"
implementation "javasabr.rlib:rlib-compiler:$rlibVersion"
implementation "javasabr.rlib:rlib-concurrent:$rlibVersion"
implementation "javasabr.rlib:rlib-geometry:$rlibVersion"
implementation "javasabr.rlib:rlib-logger-api:$rlibVersion"
implementation "javasabr.rlib:rlib-logger-slf4j:$rlibVersion"
implementation "javasabr.rlib:rlib-plugin-system:$rlibVersion"
implementation "javasabr.rlib:rlib-reference:$rlibVersion"
implementation "javasabr.rlib:rlib-reusable:$rlibVersion"
implementation "javasabr.rlib:rlib-fx:$rlibVersion"
implementation "javasabr.rlib:rlib-network:$rlibVersion"
implementation "javasabr.rlib:rlib-mail:$rlibVersion"
implementation "javasabr.rlib:rlib-testcontainers:$rlibVersion"
}
```
## Most interesting parts:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.version = "10.0.alpha"
rootProject.version = "10.0.alpha1"
group = 'javasabr.rlib'

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ default Iterator<E> iterator() {
*/
int indexOf(@Nullable Object object);

/**
* @return the index of the object or -1.
*/
<T> int indexOf(Function<E, T> getter, @Nullable Object object);

int lastIndexOf(@Nullable Object object);

<T > T[] toArray(T[] newArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import javasabr.rlib.functions.ObjIntPredicate;
import javasabr.rlib.functions.ObjObjLongConsumer;
import javasabr.rlib.functions.TriConsumer;
import org.jspecify.annotations.Nullable;

public interface ArrayIterationFunctions<E> {

@Nullable
<T> E findAny(T arg1, BiPredicate<? super E, T> filter);
<A> E findAny(A arg1, BiPredicate<? super E, A> filter);

<T> ArrayIterationFunctions<E> forEach(T arg1, BiConsumer<? super E, T> consumer);
@Nullable
E findAny(int arg1, ObjIntPredicate<? super E> filter);

<A> ArrayIterationFunctions<E> forEach(A arg1, BiConsumer<? super E, A> consumer);

<F, S> ArrayIterationFunctions<E> forEach(F arg1, S arg2, TriConsumer<? super E, F, S> consumer);
<A, B> ArrayIterationFunctions<E> forEach(A arg1, B arg2, TriConsumer<? super E, A, B> consumer);

<F> ArrayIterationFunctions<E> forEach(F arg1, long arg2, ObjObjLongConsumer<? super E, F> consumer);
<A> ArrayIterationFunctions<E> forEach(A arg1, long arg2, ObjObjLongConsumer<? super E, A> consumer);

<T> boolean anyMatch(T arg1, BiPredicate<? super E, T> filter);
<A> boolean anyMatch(A arg1, BiPredicate<? super E, A> filter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
*/
public interface IntArray extends Iterable<Integer>, Serializable, Cloneable, RandomAccess {

ImmutableIntArray EMPTY = new ImmutableIntArray();

static IntArray empty() {
return new ImmutableIntArray();
return EMPTY;
}

static IntArray of(int e1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package javasabr.rlib.collections.array;

import javasabr.rlib.collections.operation.LockableOperations;
import javasabr.rlib.collections.operation.LockableSource;
import javasabr.rlib.common.ThreadSafe;

public interface LockableArray<E> extends MutableArray<E>, LockableSource, ThreadSafe {

LockableOperations<LockableArray<E>> operations();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
*/
public interface LongArray extends Iterable<Long>, Serializable, Cloneable, RandomAccess {

ImmutableLongArray EMPTY = new ImmutableLongArray();

static LongArray empty() {
return new ImmutableLongArray();
return EMPTY;
}

static LongArray of(long e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
public interface ReversedArrayIterationFunctions<E> {

@Nullable
<T> E findAny(T arg1, BiPredicate<T, ? super E> filter);
<A> E findAny(A arg1, BiPredicate<A, ? super E> filter);

<T> ReversedArrayIterationFunctions<E> forEach(T arg1, BiConsumer<T, ? super E> consumer);
<A> ReversedArrayIterationFunctions<E> forEach(A arg1, BiConsumer<A, ? super E> consumer);

<F, S> ReversedArrayIterationFunctions<E> forEach(F arg1, S arg2, TriConsumer<F, S, ? super E> consumer);
<A, B> ReversedArrayIterationFunctions<E> forEach(A arg1, B arg2, TriConsumer<A, B, ? super E> consumer);

<T> boolean anyMatch(T arg1, BiPredicate<T, ? super E> filter);
<A> boolean anyMatch(A arg1, BiPredicate<A, ? super E> filter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ public int indexOf(@Nullable Object object) {
return -1;
}

@Override
public <T> int indexOf(Function<E, T> getter, @Nullable Object object) {
if (object == null) {
return -1;
}
@Nullable E[] wrapped = wrapped();
for (int i = 0, length = size(); i < length; i++) {
//noinspection DataFlowIssue
if (object.equals(getter.apply(wrapped[i]))) {
return i;
}
}
return -1;
}

@Override
public int lastIndexOf(@Nullable Object object) {
if (object == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.concurrent.atomic.AtomicInteger;
import javasabr.rlib.collections.array.LockableArray;
import javasabr.rlib.collections.operation.LockableOperations;
import javasabr.rlib.collections.operation.impl.DefaultLockableOperations;
import javasabr.rlib.common.util.ArrayUtils;
import lombok.AccessLevel;
import lombok.Getter;
Expand Down Expand Up @@ -57,4 +59,9 @@ protected int getAndIncrementSize() {
protected int decrementAnGetSize() {
return size.decrementAndGet();
}

@Override
public LockableOperations<LockableArray<E>> operations() {
return new DefaultLockableOperations<>(this);
}
}
Loading
Loading