Skip to content

Commit

Permalink
Merge pull request #283 from JarvisCraft/1.0.0-rc.7
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvisCraft authored Nov 4, 2021
2 parents 2d09a42 + c9de81b commit b556556
Show file tree
Hide file tree
Showing 29 changed files with 518 additions and 176 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ko_fi: progrm_jarvis
custom:
- 'https://qiwi.com/n/PROgrammerJARvis'
- 'https://yoomoney.ru/to/410013423232443'
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v2.4.0

- name: Set up Java 17 & Deployment credentials
uses: actions/setup-java@main
uses: actions/setup-java@v2.3.1
with:
distribution: 'zulu'
java-version: '17'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v2.4.0

- name: Set up Java 17 & Deployment credentials
uses: actions/setup-java@main
uses: actions/setup-java@v2.3.1
with:
distribution: 'zulu'
java-version: '17'
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

on: [ pull_request ]

jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Set up Java 17
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'

- name: Run tests
run: mvn -B test

check-javadocs:
name: Check Javadocs
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Set up Java 17
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'

- name: Install artifacts
run: mvn -B install -Dmaven.test.skip=true

- name: Try to generate Javadocs
run: mvn -B javadoc:javadoc
21 changes: 0 additions & 21 deletions .github/workflows/test.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class LazyIteratorToCollectionWrapper<E, C extends Collection<E>> impleme
}

/**
* Checks whether or not the wrapped iterator contains the specified element.
* Checks whether the wrapped iterator contains the specified element.
*
* @param element element to check for containment
* @return {@code true} if the element is contained in the wrapped iterator and {@code false} otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public interface DataSerializer<T> {
* @implNote delegates to {@link #write(DataOutputStream, Object)}
* @implSpec should not be overridden
*/
@SneakyThrows(IOException.class)
default void writeUnchecked(final @NotNull DataOutputStream output, final T object) {
writeUnchecked(output, object);
write(output, object);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,32 @@ public class DataSerializers {

/* ************************************************ Collections ************************************************ */

public <C extends Collection<T>, T> @NotNull DataSerializer<C> collectionDataSerializer(
final @NonNull DataSerializers.SizeAwareFactory<@NotNull C> collectionFactory,
public <C extends Collection<T>, T> @NotNull DataSerializer<@NotNull C> collectionDataSerializer(
final DataSerializers.@NonNull SizeAwareFactory<C> collectionFactory,
final @NonNull DataSerializer<T> elementSerializer
) {
return new CollectionDataSerializer<>(collectionFactory, elementSerializer);
}

public <T> @NotNull DataSerializer<Collection<T>> collectionDataSerializer(
public <T> @NotNull DataSerializer<@NotNull Collection<T>> collectionDataSerializer(
final @NonNull DataSerializer<T> elementSerializer) {
return collectionDataSerializer(ArrayList::new, elementSerializer);
}

public <T> @NotNull DataSerializer<List<T>> listDataSerializer(
public <T> @NotNull DataSerializer<@NotNull List<T>> listDataSerializer(
final @NonNull DataSerializer<T> elementSerializer
) {
return collectionDataSerializer(ArrayList::new, elementSerializer);
}

public <T> @NotNull DataSerializer<Set<T>> setDataSerializer(
public <T> @NotNull DataSerializer<@NotNull Set<T>> setDataSerializer(
final @NonNull DataSerializer<T> elementSerializer
) {
return collectionDataSerializer(HashSet::new, elementSerializer);
}

public <M extends Map<K, V>, K, V> @NotNull DataSerializer<M> mapDataSerializer(
final @NonNull DataSerializers.SizeAwareFactory<@NotNull M> mapFactory,
public <M extends Map<K, V>, K, V> @NotNull DataSerializer<@NotNull M> mapDataSerializer(
final DataSerializers.@NonNull SizeAwareFactory<M> mapFactory,
final @NonNull DataSerializer<K> keySerializer,
final @NonNull DataSerializer<V> valueSerializer
) {
Expand Down Expand Up @@ -473,7 +473,7 @@ public void write(final @NotNull DataOutputStream out, final @NotNull UUID uuid)

@Override
public @NotNull UUID fromByteArray(final byte @NotNull [] byteArray) throws IOException {
if (byteArray.length != 16) throw new IOException("Byte array should be of length 16");
if (byteArray.length != UuidUtil.UUID_BYTES) throw new IOException("Byte array should be of length 16");

return UuidUtil.uuidFromBytes(byteArray);
}
Expand All @@ -493,19 +493,20 @@ public void write(final @NotNull DataOutputStream out, final @NotNull UUID uuid)

@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
private static final class CollectionDataSerializer<C extends Collection<T>, T> implements DataSerializer<C> {
private static final class CollectionDataSerializer<C extends Collection<T>, T>
implements DataSerializer<@NotNull C> {

@NotNull DataSerializers.SizeAwareFactory<@NotNull C> collectionFactory;
DataSerializers.@NotNull SizeAwareFactory<C> collectionFactory;
@NotNull DataSerializer<T> elementSerializer;

@Override
public void write(final @NotNull DataOutputStream out, final C collection) throws IOException {
public void write(final @NotNull DataOutputStream out, final @NotNull C collection) throws IOException {
out.writeInt(collection.size());
for (val element : collection) elementSerializer.write(out, element);
}

@Override
public C read(final @NotNull DataInputStream in) throws IOException {
public @NotNull C read(final @NotNull DataInputStream in) throws IOException {
final int size;
val collection = collectionFactory.create(size = in.readInt());
for (var i = 0; i < size; i++) collection.add(elementSerializer.read(in));
Expand All @@ -516,14 +517,14 @@ public C read(final @NotNull DataInputStream in) throws IOException {

@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
private static final class MapDataSerializer<M extends Map<K, V>, K, V> implements DataSerializer<M> {
private static final class MapDataSerializer<M extends Map<K, V>, K, V> implements DataSerializer<@NotNull M> {

@NotNull DataSerializers.SizeAwareFactory<@NotNull M> mapFactory;
DataSerializers.@NotNull SizeAwareFactory<M> mapFactory;
@NotNull DataSerializer<K> keySerializer;
@NotNull DataSerializer<V> valueSerializer;

@Override
public void write(final @NotNull DataOutputStream out, final M map) throws IOException {
public void write(final @NotNull DataOutputStream out, final @NotNull M map) throws IOException {
final Set<Map.Entry<K, V>> entries;
out.writeInt((entries = map.entrySet()).size());
for (val entry : entries) {
Expand All @@ -533,7 +534,7 @@ public void write(final @NotNull DataOutputStream out, final M map) throws IOExc
}

@Override
public M read(final @NotNull DataInputStream in) throws IOException {
public @NotNull M read(final @NotNull DataInputStream in) throws IOException {
final int size;
val map = mapFactory.create(size = in.readInt());
for (var i = 0; i < size; i++) map.put(keySerializer.read(in), valueSerializer.read(in));
Expand Down
Loading

0 comments on commit b556556

Please sign in to comment.