Add binary strings
This commit is contained in:
parent
6bafed9886
commit
26448fc1b8
@ -3,7 +3,6 @@ package it.cavallium.datagen.plugin;
|
|||||||
import com.squareup.javapoet.ClassName;
|
import com.squareup.javapoet.ClassName;
|
||||||
import com.squareup.javapoet.ParameterizedTypeName;
|
import com.squareup.javapoet.ParameterizedTypeName;
|
||||||
import com.squareup.javapoet.TypeName;
|
import com.squareup.javapoet.TypeName;
|
||||||
import it.cavallium.datagen.NativeNullable;
|
|
||||||
import it.cavallium.datagen.nativedata.*;
|
import it.cavallium.datagen.nativedata.*;
|
||||||
import it.unimi.dsi.fastutil.booleans.BooleanList;
|
import it.unimi.dsi.fastutil.booleans.BooleanList;
|
||||||
import it.unimi.dsi.fastutil.bytes.ByteList;
|
import it.unimi.dsi.fastutil.bytes.ByteList;
|
||||||
@ -20,15 +19,15 @@ import java.util.stream.Stream;
|
|||||||
public final class ComputedTypeArrayNative implements ComputedTypeArray {
|
public final class ComputedTypeArrayNative implements ComputedTypeArray {
|
||||||
|
|
||||||
private final String baseType;
|
private final String baseType;
|
||||||
private final boolean byteStrings;
|
private final boolean binaryStrings;
|
||||||
|
|
||||||
private ComputedTypeNative computedChild;
|
private ComputedTypeNative computedChild;
|
||||||
private final ComputedTypeSupplier computedTypeSupplier;
|
private final ComputedTypeSupplier computedTypeSupplier;
|
||||||
|
|
||||||
public ComputedTypeArrayNative(String baseType, ComputedTypeSupplier computedTypeSupplier, boolean byteStrings) {
|
public ComputedTypeArrayNative(String baseType, ComputedTypeSupplier computedTypeSupplier, boolean binaryStrings) {
|
||||||
this.baseType = baseType;
|
this.baseType = baseType;
|
||||||
this.computedTypeSupplier = computedTypeSupplier;
|
this.computedTypeSupplier = computedTypeSupplier;
|
||||||
this.byteStrings = byteStrings;
|
this.binaryStrings = binaryStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputedType getBase() {
|
public ComputedType getBase() {
|
||||||
@ -105,7 +104,7 @@ public final class ComputedTypeArrayNative implements ComputedTypeArray {
|
|||||||
case "long" -> ClassName.get(ArraylongSerializer.class);
|
case "long" -> ClassName.get(ArraylongSerializer.class);
|
||||||
case "float" -> ClassName.get(ArrayfloatSerializer.class);
|
case "float" -> ClassName.get(ArrayfloatSerializer.class);
|
||||||
case "double" -> ClassName.get(ArraydoubleSerializer.class);
|
case "double" -> ClassName.get(ArraydoubleSerializer.class);
|
||||||
case "String" -> byteStrings ? ClassName.get(ArrayBinaryStringSerializer.class) : ClassName.get(ArrayStringSerializer.class);
|
case "String" -> binaryStrings ? ClassName.get(ArrayBinaryStringSerializer.class) : ClassName.get(ArrayStringSerializer.class);
|
||||||
case "Int52" -> ClassName.get(ArrayInt52Serializer.class);
|
case "Int52" -> ClassName.get(ArrayInt52Serializer.class);
|
||||||
default -> throw new UnsupportedOperationException();
|
default -> throw new UnsupportedOperationException();
|
||||||
};
|
};
|
||||||
@ -113,9 +112,13 @@ public final class ComputedTypeArrayNative implements ComputedTypeArray {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldLocation getJSerializerInstance(String basePackageName) {
|
public FieldLocation getJSerializerInstance(String basePackageName) {
|
||||||
var className = ClassName.get(Serializers.class);
|
if (baseType.equals("String") && binaryStrings) {
|
||||||
var serializerFieldName = "Array" + baseType + "SerializerInstance";
|
return new FieldLocation(ClassName.get(Serializers.class), "NullableBinaryStringSerializerInstance");
|
||||||
return new FieldLocation(className, serializerFieldName);
|
} else {
|
||||||
|
var className = ClassName.get(Serializers.class);
|
||||||
|
var serializerFieldName = "Array" + baseType + "SerializerInstance";
|
||||||
|
return new FieldLocation(className, serializerFieldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,7 +65,11 @@ public final class ComputedTypeNative implements ComputedType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldLocation getJSerializerInstance(String basePackageName) {
|
public FieldLocation getJSerializerInstance(String basePackageName) {
|
||||||
return new FieldLocation(ClassName.get(Serializers.class), type + "SerializerInstance");
|
if (type.equals("String") && binaryStrings) {
|
||||||
|
return new FieldLocation(ClassName.get(Serializers.class), "BinaryStringSerializerInstance");
|
||||||
|
} else {
|
||||||
|
return new FieldLocation(ClassName.get(Serializers.class), type + "SerializerInstance");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,13 +106,17 @@ public final class ComputedTypeNullableNative implements ComputedTypeNullable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldLocation getJSerializerInstance(String basePackageName) {
|
public FieldLocation getJSerializerInstance(String basePackageName) {
|
||||||
var className = switch (baseType) {
|
if (baseType.equals("String") && binaryStrings) {
|
||||||
case "boolean", "byte", "short", "char", "int", "long", "float", "double", "String", "Int52" ->
|
return new FieldLocation(ClassName.get(Serializers.class), "NullableBinaryStringSerializerInstance");
|
||||||
ClassName.get(Serializers.class);
|
} else {
|
||||||
default -> throw new UnsupportedOperationException();
|
var className = switch (baseType) {
|
||||||
};
|
case "boolean", "byte", "short", "char", "int", "long", "float", "double", "String", "Int52" ->
|
||||||
var serializerFieldName = "Nullable" + baseType + "SerializerInstance";
|
ClassName.get(Serializers.class);
|
||||||
return new FieldLocation(className, serializerFieldName);
|
default -> throw new UnsupportedOperationException();
|
||||||
|
};
|
||||||
|
var serializerFieldName = "Nullable" + baseType + "SerializerInstance";
|
||||||
|
return new FieldLocation(className, serializerFieldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user