Remove exceptions
This commit is contained in:
parent
d103367b43
commit
a97a5ee9b5
@ -68,7 +68,7 @@ public class SourcesGenerator {
|
|||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SourcesGenerator.class);
|
private static final Logger logger = LoggerFactory.getLogger(SourcesGenerator.class);
|
||||||
private static final boolean OVERRIDE_ALL_NULLABLE_METHODS = false;
|
private static final boolean OVERRIDE_ALL_NULLABLE_METHODS = false;
|
||||||
private static final String SERIAL_VERSION = "1";
|
private static final String SERIAL_VERSION = "2";
|
||||||
|
|
||||||
private final DataModel dataModel;
|
private final DataModel dataModel;
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package it.cavallium.data.generator;
|
package it.cavallium.data.generator;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface DataInitializer<T> {
|
public interface DataInitializer<T> {
|
||||||
|
|
||||||
@NotNull T initialize() throws IOException;
|
@NotNull T initialize();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package it.cavallium.data.generator;
|
package it.cavallium.data.generator;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface DataUpgrader<T, U> {
|
public interface DataUpgrader<T, U> {
|
||||||
|
|
||||||
@NotNull U upgrade(@NotNull T data) throws IOException;
|
@NotNull U upgrade(@NotNull T data);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package it.cavallium.data.generator.nativedata;
|
package it.cavallium.data.generator.nativedata;
|
||||||
|
|
||||||
import it.cavallium.data.generator.DataUpgrader;
|
import it.cavallium.data.generator.DataUpgrader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UpgradeUtil {
|
public class UpgradeUtil {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <A, B> List<B> upgradeArray(List<A> from, DataUpgrader<A, B> upgrader)
|
public static <A, B> List<B> upgradeArray(List<A> from, DataUpgrader<A, B> upgrader) {
|
||||||
throws IOException {
|
|
||||||
Object[] array;
|
Object[] array;
|
||||||
if (from instanceof ImmutableWrappedArrayList<A> immutableWrappedArrayList) {
|
if (from instanceof ImmutableWrappedArrayList<A> immutableWrappedArrayList) {
|
||||||
array = immutableWrappedArrayList.a;
|
array = immutableWrappedArrayList.a;
|
||||||
@ -20,7 +18,7 @@ public class UpgradeUtil {
|
|||||||
return (ImmutableWrappedArrayList<B>) new ImmutableWrappedArrayList<>(array);
|
return (ImmutableWrappedArrayList<B>) new ImmutableWrappedArrayList<>(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <A, B> B upgradeNullable(A nullableValue, DataUpgrader<A, B> upgrader) throws IOException {
|
public static <A, B> B upgradeNullable(A nullableValue, DataUpgrader<A, B> upgrader) {
|
||||||
if (nullableValue == null) {
|
if (nullableValue == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,6 @@ import it.cavallium.stream.SafeByteArrayInputStream;
|
|||||||
import it.cavallium.stream.SafeByteArrayOutputStream;
|
import it.cavallium.stream.SafeByteArrayOutputStream;
|
||||||
import it.cavallium.stream.SafeDataInputStream;
|
import it.cavallium.stream.SafeDataInputStream;
|
||||||
import it.cavallium.stream.SafeDataOutputStream;
|
import it.cavallium.stream.SafeDataOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -12,7 +11,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
public class TestInt52Serializer {
|
public class TestInt52Serializer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInt52Serialization() throws IOException {
|
public void testInt52Serialization() {
|
||||||
for (int i = 0; i <= 300; i++) {
|
for (int i = 0; i <= 300; i++) {
|
||||||
testInt52Serialization(i);
|
testInt52Serialization(i);
|
||||||
}
|
}
|
||||||
@ -21,7 +20,7 @@ public class TestInt52Serializer {
|
|||||||
testInt52Serialization(999619292661L);
|
testInt52Serialization(999619292661L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInt52Serialization(long n) throws IOException {
|
public void testInt52Serialization(long n) {
|
||||||
var serializer = new Int52Serializer();
|
var serializer = new Int52Serializer();
|
||||||
byte[] out;
|
byte[] out;
|
||||||
try (var baos = new SafeByteArrayOutputStream()) {
|
try (var baos = new SafeByteArrayOutputStream()) {
|
||||||
@ -37,7 +36,7 @@ public class TestInt52Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInt52OptionalSerialization() throws IOException {
|
public void testInt52OptionalSerialization() {
|
||||||
testInt52OptionalSerialization(null);
|
testInt52OptionalSerialization(null);
|
||||||
for (long i = 0; i <= 300; i++) {
|
for (long i = 0; i <= 300; i++) {
|
||||||
testInt52OptionalSerialization(i);
|
testInt52OptionalSerialization(i);
|
||||||
@ -45,7 +44,7 @@ public class TestInt52Serializer {
|
|||||||
testInt52OptionalSerialization(0xF_FF_FF_FF_FF_FF_FFL);
|
testInt52OptionalSerialization(0xF_FF_FF_FF_FF_FF_FFL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInt52OptionalSerialization(@Nullable Long n) throws IOException {
|
public void testInt52OptionalSerialization(@Nullable Long n) {
|
||||||
var serializer = new NullableInt52Serializer();
|
var serializer = new NullableInt52Serializer();
|
||||||
byte[] out;
|
byte[] out;
|
||||||
try (var baos = new SafeByteArrayOutputStream()) {
|
try (var baos = new SafeByteArrayOutputStream()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user