-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from JarvisCraft/1.0.0-rc.11
- Loading branch information
Showing
15 changed files
with
197 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,19 +22,19 @@ jobs: | |
- uses: actions/[email protected] | ||
|
||
- 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/[email protected].15 | ||
uses: github/codeql-action/[email protected].23 | ||
with: | ||
languages: java | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/[email protected].15 | ||
uses: github/codeql-action/[email protected].23 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/[email protected].15 | ||
uses: github/codeql-action/[email protected].23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
- uses: actions/[email protected] | ||
|
||
- 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
- uses: actions/[email protected] | ||
|
||
- 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ jobs: | |
- uses: actions/[email protected] | ||
|
||
- 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/[email protected] | ||
|
||
- 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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/ArrayUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <T> the type of source elements | ||
* @param <R> the type of target elements | ||
*/ | ||
public static <T, R> 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 <T> the type of source elements | ||
* @param <R> the type of target elements | ||
*/ | ||
public static <T, R> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.