diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml
index 117ed513..50cd3db5 100644
--- a/.github/workflows/codeql-analysis.yaml
+++ b/.github/workflows/codeql-analysis.yaml
@@ -22,19 +22,19 @@ jobs:
- uses: actions/checkout@v3.0.2
- name: Set up Java 17
- uses: actions/setup-java@v3.4.0
+ uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'
- name: Initialize CodeQL
- uses: github/codeql-action/init@v2.1.15
+ uses: github/codeql-action/init@v2.1.23
with:
languages: java
- name: Autobuild
- uses: github/codeql-action/autobuild@v2.1.15
+ uses: github/codeql-action/autobuild@v2.1.23
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v2.1.15
+ uses: github/codeql-action/analyze@v2.1.23
diff --git a/.github/workflows/deploy-release.yaml b/.github/workflows/deploy-release.yaml
index bae5ad05..a026c263 100644
--- a/.github/workflows/deploy-release.yaml
+++ b/.github/workflows/deploy-release.yaml
@@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3.0.2
- name: Set up Java 17 & Deployment credentials
- uses: actions/setup-java@v3.4.0
+ uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: '17'
@@ -24,7 +24,7 @@ jobs:
gpg-private-key: ${{ secrets.CODE_SIGNING_GPG_PRIVATE_KEY }}
gpg-passphrase: CODE_SIGNING_GPG_KEY_PASSPHRASE
- - uses: jactions/maven-version@v1.0.1
+ - uses: jactions/maven-version@v1.1.0
id: get_version
- name: Deploy release
diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml
index ee63090b..aee8e2bb 100644
--- a/.github/workflows/deploy-snapshot.yaml
+++ b/.github/workflows/deploy-snapshot.yaml
@@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3.0.2
- name: Set up Java 17 & Deployment credentials
- uses: actions/setup-java@v3.4.0
+ uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: '17'
@@ -24,7 +24,7 @@ jobs:
gpg-private-key: ${{ secrets.CODE_SIGNING_GPG_PRIVATE_KEY }}
gpg-passphrase: CODE_SIGNING_GPG_KEY_PASSPHRASE
- - uses: jactions/maven-version@v1.0.1
+ - uses: jactions/maven-version@v1.1.0
id: get_version
- name: Deploy snapshot
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 112df70d..6fd29098 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3.0.2
- name: Set up Java 17
- uses: actions/setup-java@v3.4.0
+ uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: '17'
@@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3.0.2
- name: Set up Java 17
- uses: actions/setup-java@v3.4.0
+ uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: '17'
diff --git a/SECURITY.md b/SECURITY.md
index a751d0ae..90f3fd3e 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -4,8 +4,8 @@
| Version | Supported |
|---------------| ------------------ |
-| [1.0.0-rc.10] | :heavy_check_mark: |
-| < 1.0.0-rc.10 | :x: |
+| [1.0.0-rc.11] | :heavy_check_mark: |
+| < 1.0.0-rc.11 | :x: |
## Reporting a Vulnerability
@@ -16,4 +16,4 @@ These are checked regularly and are the primary support channel.
-[1.0.0-rc.10]: https://mvnrepository.com/artifact/ru.progrm-jarvis/padla/1.0.0-rc.10
+[1.0.0-rc.11]: https://mvnrepository.com/artifact/ru.progrm-jarvis/padla/1.0.0-rc.11
diff --git a/java-commons/pom.xml b/java-commons/pom.xml
index 2384fa1d..da5e9dec 100644
--- a/java-commons/pom.xml
+++ b/java-commons/pom.xml
@@ -6,7 +6,7 @@
ru.progrm-jarvis
padla-parent
- 1.0.0-rc.10
+ 1.0.0-rc.11
../padla-parent
java-commons
diff --git a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/object/Result.java b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/object/Result.java
index e34c945c..5f594402 100644
--- a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/object/Result.java
+++ b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/object/Result.java
@@ -134,8 +134,10 @@ public interface Result extends Supplier {
* @see #from(Optional) alternative with default (i.e. null) error
*/
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") // convertion from optional itself
- static @NotNull Result from(final @NonNull Optional extends T> optional,
- final @NonNull Supplier extends E> errorSupplier) {
+ static @NotNull Result from(
+ final @NonNull Optional extends T> optional,
+ final @NonNull Supplier extends E> errorSupplier
+ ) {
return optional.>map(Result::success).orElseGet(() -> error(errorSupplier.get()));
}
@@ -401,17 +403,25 @@ default T orElseSneakyThrow(
* Gets the value of this result if this is a {@link #isSuccess() successful}
* otherwise returning default value.
*
- * @param defaultValue default value to be returned if this is an {@link #isError()} error value}
+ * @param defaultValue default value to be returned if this is an {@link #isError() error value}
* @return successful value if this a {@link #isSuccess() successful result} or {@code defaultValue} otherwise
*/
T orDefault(T defaultValue);
+ /**
+ * Gets the value of this result if this is a {@link #isSuccess() successful}
+ * otherwise returning {@code null}.
+ *
+ * @return successful value if this a {@link #isSuccess() successful result} or {@code null} otherwise
+ */
+ @Nullable T orNull();
+
/**
* Gets the value of this result if this is a {@link #isSuccess() successful}
* otherwise returning the value got by using the specified supplier.
*
* @param defaultValueSupplier supplier of the default value
- * to be returned if this is an {@link #isError()} error value}
+ * to be returned if this is an {@link #isError() error value}
* @return successful value if this a {@link #isSuccess() successful result} or got default otherwise
*/
T orGetDefault(@NonNull Supplier extends T> defaultValueSupplier);
@@ -421,7 +431,7 @@ default T orElseSneakyThrow(
* otherwise returning the value computed by applying the given function to the {@link #unwrapError() error value}.
*
* @param defaultValueFactory factory used for creation of the default value
- * to be returned if this is an {@link #isError()} error value}
+ * to be returned if this is an {@link #isError() error value}
* @return successful value if this a {@link #isSuccess() successful result} or the computed default otherwise
*/
T orComputeDefault(@NonNull Function super E, ? extends T> defaultValueFactory);
@@ -488,6 +498,45 @@ default E errorOrElseSneakyThrow(
return errorOrElseThrow(exceptionFactory);
}
+ /**
+ * Gets the error of this result if this is an {@link #isError() error}
+ * otherwise returning default value.
+ *
+ * @param defaultError default value to be returned if this is an {@link #isSuccess() successful result}
+ * @return error value if this an {@link #isError() error result} or {@code defaultError} otherwise
+ */
+ E errorOrDefault(E defaultError);
+
+ /**
+ * Gets the error of this result if this is an {@link #isError() error}
+ * otherwise returning {@code null}.
+ *
+ * @return error value if this an {@link #isError() error result} or {@code null} otherwise
+ */
+ @Nullable E errorOrNull();
+
+ /**
+ * Gets the value of this result if this is an {@link #isError() error}
+ * otherwise returning the value got by using the specified supplier.
+ *
+ * @param defaultErrorSupplier supplier of the default error
+ * to be returned if this is a {@link #isSuccess() successful value}
+ * @return error value if this an {@link #isError() error result} or got default otherwise
+ */
+ E errorOrGetDefault(@NonNull Supplier extends E> defaultErrorSupplier);
+
+ /**
+ * Gets the value of this result if this is a {@link #isSuccess() successful}
+ * otherwise returning the value computed by applying the given function to the {@link #unwrapError() error value}.
+ *
+ * @param defaultErrorFactory factory used for creation of the default error
+ * to be returned if this is a {@link #isSuccess() successful value}
+ * @return successful value if this an {@link #isError() error result} or the computed default otherwise
+ */
+ E errorOrComputeDefault(@NonNull Function super T, ? extends E> defaultErrorFactory);
+
+ /* ********************************************** Handling methods ********************************************** */
+
/**
* Invokes the given function if this result is a {@link #isSuccess() successful result}.
*
@@ -727,6 +776,11 @@ public T orDefault(final T defaultValue) {
return value;
}
+ @Override
+ public @Nullable T orNull() {
+ return value;
+ }
+
@Override
public T orGetDefault(final @NonNull Supplier extends T> defaultValueSupplier) {
return value;
@@ -754,6 +808,26 @@ public E errorOrElseThrow(
throw exceptionSupplier.apply(value);
}
+ @Override
+ public E errorOrDefault(final E defaultError) {
+ return defaultError;
+ }
+
+ @Override
+ public @Nullable E errorOrNull() {
+ return null;
+ }
+
+ @Override
+ public E errorOrGetDefault(@NonNull final Supplier extends E> defaultErrorSupplier) {
+ return defaultErrorSupplier.get();
+ }
+
+ @Override
+ public E errorOrComputeDefault(@NonNull final Function super T, ? extends E> defaultErrorFactory) {
+ return defaultErrorFactory.apply(value);
+ }
+
@Override
public void ifSuccess(final @NonNull Consumer super T> successConsumer) {
successConsumer.accept(value);
@@ -928,6 +1002,11 @@ public T orDefault(final T defaultValue) {
return defaultValue;
}
+ @Override
+ public @Nullable T orNull() {
+ return null;
+ }
+
@Override
public T orGetDefault(final @NonNull Supplier extends T> defaultValueSupplier) {
return defaultValueSupplier.get();
@@ -955,6 +1034,26 @@ public E errorOrElseThrow(
return error;
}
+ @Override
+ public E errorOrDefault(final E defaultError) {
+ return error;
+ }
+
+ @Override
+ public @Nullable E errorOrNull() {
+ return error;
+ }
+
+ @Override
+ public E errorOrGetDefault(@NonNull final Supplier extends E> defaultErrorSupplier) {
+ return error;
+ }
+
+ @Override
+ public E errorOrComputeDefault(@NonNull final Function super T, ? extends E> defaultErrorFactory) {
+ return error;
+ }
+
@Override
public void ifSuccess(final @NonNull Consumer super T> successConsumer) {}
diff --git a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/ArrayUtils.java b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/ArrayUtils.java
new file mode 100644
index 00000000..d5b3a938
--- /dev/null
+++ b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/ArrayUtils.java
@@ -0,0 +1,63 @@
+package ru.progrm_jarvis.javacommons.util;
+
+import lombok.NonNull;
+import lombok.experimental.UtilityClass;
+import lombok.val;
+import lombok.var;
+import org.jetbrains.annotations.NotNull;
+
+import java.lang.reflect.Array;
+import java.util.function.Function;
+import java.util.function.IntFunction;
+
+/**
+ * Utilities for working with arrays.
+ */
+@UtilityClass
+public class ArrayUtils {
+
+ /**
+ * Maps the given array by-element using the provided function.
+ *
+ * @param source source array
+ * @param mappingFunction function used to map elements
+ * @param arrayFactory function used to create a new array by its length
+ * @return created array
+ * @param the type of source elements
+ * @param the type of target elements
+ */
+ public static R @NotNull [] map(
+ final T @NonNull [] source,
+ final @NonNull Function super T, ? extends R> mappingFunction,
+ final @NonNull IntFunction extends R @NotNull []> arrayFactory
+ ) {
+ final int length;
+ val target = arrayFactory.apply(length = source.length);
+ for (var i = 0; i < length; i++) target[i] = mappingFunction.apply(source[i]);
+
+ return target;
+ }
+ /**
+ * Maps the given array by-element using the provided function.
+ *
+ * @param source source array
+ * @param mappingFunction function used to map elements
+ * @param typeHint pseudo-array of the same type as the target array
+ * @return created array
+ * @param the type of source elements
+ * @param the type of target elements
+ */
+ public static R @NotNull [] map(
+ final T @NonNull [] source,
+ final @NonNull Function super T, ? extends R> mappingFunction,
+ @TypeHints.TypeHint
+ final @NonNull R... typeHint
+ ) {
+ final int length;
+ @SuppressWarnings("unchecked")
+ val target = (R[]) Array.newInstance(TypeHints.resolve(typeHint), length = source.length);
+ for (var i = 0; i < length; i++) target[i] = mappingFunction.apply(source[i]);
+
+ return target;
+ }
+}
diff --git a/java-commons/src/main/java9/module-info.java b/java-commons/src/main/java9/module-info.java
index 538529e1..2132a06d 100644
--- a/java-commons/src/main/java9/module-info.java
+++ b/java-commons/src/main/java9/module-info.java
@@ -5,7 +5,7 @@
module ru.progrm_jarvis.javacommons {
// optional dependencies
requires org.objectweb.asm;
- requires javassist;
+ requires org.javassist;
requires static lombok;
requires static org.jetbrains.annotations;
diff --git a/padla-bom/pom.xml b/padla-bom/pom.xml
index ed57e89b..8510a4c1 100644
--- a/padla-bom/pom.xml
+++ b/padla-bom/pom.xml
@@ -6,7 +6,7 @@
ru.progrm-jarvis
padla
- 1.0.0-rc.10
+ 1.0.0-rc.11
padla-bom
pom
@@ -20,17 +20,17 @@
ru.progrm-jarvis
java-commons
- 1.0.0-rc.10
+ 1.0.0-rc.11
ru.progrm-jarvis
reflector
- 1.0.0-rc.10
+ 1.0.0-rc.11
ru.progrm-jarvis
ultimate-messenger
- 1.0.0-rc.10
+ 1.0.0-rc.11
diff --git a/padla-parent/pom.xml b/padla-parent/pom.xml
index b008ced0..929daf4c 100644
--- a/padla-parent/pom.xml
+++ b/padla-parent/pom.xml
@@ -6,7 +6,7 @@
ru.progrm-jarvis
padla
- 1.0.0-rc.10
+ 1.0.0-rc.11
padla-parent
pom
@@ -55,14 +55,14 @@
org.junit
junit-bom
- 5.8.2
+ 5.9.0
pom
import
org.mockito
mockito-bom
- 4.6.1
+ 4.8.0
pom
import
diff --git a/pom.xml b/pom.xml
index ddb96cf6..8b2e467f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
ru.progrm-jarvis
padla
- 1.0.0-rc.10
+ 1.0.0-rc.11
padla-bom
padla-parent
@@ -139,7 +139,7 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.2.2
+ 3.3.0
@@ -158,7 +158,7 @@
org.apache.drill.tools
drill-fmpp-maven-plugin
- 1.20.0-hadoop2
+ 1.20.2
generate-fmpp
@@ -200,7 +200,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.4.0
+ 3.4.1
${java.version.minimal}
@@ -271,7 +271,7 @@
org.javassist
javassist
- 3.29.0-GA
+ 3.29.2-GA
provided
true
diff --git a/reflector/pom.xml b/reflector/pom.xml
index de9c8d48..329f4e40 100644
--- a/reflector/pom.xml
+++ b/reflector/pom.xml
@@ -6,7 +6,7 @@
ru.progrm-jarvis
padla-parent
- 1.0.0-rc.10
+ 1.0.0-rc.11
../padla-parent
reflector
diff --git a/ultimate-messenger/pom.xml b/ultimate-messenger/pom.xml
index bf9b4405..dc82dd53 100644
--- a/ultimate-messenger/pom.xml
+++ b/ultimate-messenger/pom.xml
@@ -6,7 +6,7 @@
ru.progrm-jarvis
padla-parent
- 1.0.0-rc.10
+ 1.0.0-rc.11
../padla-parent
ultimate-messenger
diff --git a/ultimate-messenger/src/main/java9/module-info.java b/ultimate-messenger/src/main/java9/module-info.java
index 94593223..070072f8 100644
--- a/ultimate-messenger/src/main/java9/module-info.java
+++ b/ultimate-messenger/src/main/java9/module-info.java
@@ -10,7 +10,7 @@
requires java.logging;
// optional dependencies
requires org.objectweb.asm;
- requires javassist;
+ requires org.javassist;
requires static lombok;
requires static org.jetbrains.annotations;