io.activej.fs.tcp._RemoteFsResponses$InfoFinished_DslJsonConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activej-fs Show documentation
Show all versions of activej-fs Show documentation
Provides tools for building efficient, scalable local, remote or clustered file servers.
It utilizes ActiveJ CSP for fast and reliable file transfer.
package io.activej.fs.tcp;
public class _RemoteFsResponses$InfoFinished_DslJsonConverter implements com.dslplatform.json.Configuration {
private static final java.nio.charset.Charset utf8 = java.nio.charset.Charset.forName("UTF-8");
@Override
public void configure(com.dslplatform.json.DslJson __dsljson) {
ObjectFormatConverter objectConverter = new ObjectFormatConverter(__dsljson);
__dsljson.registerReader(io.activej.fs.tcp.RemoteFsResponses.InfoFinished.class, objectConverter);
__dsljson.registerWriter(io.activej.fs.tcp.RemoteFsResponses.InfoFinished.class, objectConverter);
}
public final static class ObjectFormatConverter implements com.dslplatform.json.runtime.FormatConverter {
private final boolean alwaysSerialize;
private final com.dslplatform.json.DslJson __dsljson;
private com.dslplatform.json.JsonReader.ReadObject reader_metadata;
private com.dslplatform.json.JsonReader.ReadObject reader_metadata() {
if (reader_metadata == null) {
java.lang.reflect.Type manifest = io.activej.fs.FileMetadata.class;
reader_metadata = __dsljson.tryFindReader(manifest);
if (reader_metadata == null) {
throw new com.dslplatform.json.ConfigurationException("Unable to find reader for " + manifest + ". Enable runtime conversion by initializing DslJson with new DslJson<>(Settings.basicSetup())");
}
}
return reader_metadata;
}
private com.dslplatform.json.JsonWriter.WriteObject writer_metadata;
private com.dslplatform.json.JsonWriter.WriteObject writer_metadata() {
if (writer_metadata == null) {
java.lang.reflect.Type manifest = io.activej.fs.FileMetadata.class;
writer_metadata = __dsljson.tryFindWriter(manifest);
if (writer_metadata == null) {
throw new com.dslplatform.json.ConfigurationException("Unable to find writer for " + manifest + ". Enable runtime conversion by initializing DslJson with new DslJson<>(Settings.basicSetup())");
}
}
return writer_metadata;
}
public ObjectFormatConverter(com.dslplatform.json.DslJson __dsljson) {
this.alwaysSerialize = !__dsljson.omitDefaults;
this.__dsljson = __dsljson;
}
private static final byte[] quoted_metadata = "\"metadata\":".getBytes(utf8);
private static final byte[] name_metadata = "metadata".getBytes(utf8);
public final void write(final com.dslplatform.json.JsonWriter writer, final io.activej.fs.tcp.RemoteFsResponses.InfoFinished instance) {
if (instance == null) writer.writeNull();
else {
writer.writeByte((byte)'{');
if (alwaysSerialize) { writeContentFull(writer, instance); writer.writeByte((byte)'}'); }
else if (writeContentMinimal(writer, instance)) writer.getByteBuffer()[writer.size() - 1] = '}';
else writer.writeByte((byte)'}');
}
}
public void writeContentFull(final com.dslplatform.json.JsonWriter writer, final io.activej.fs.tcp.RemoteFsResponses.InfoFinished instance) {
writer.writeAscii(quoted_metadata);
if (instance.getMetadata() == null) writer.writeNull();
else writer_metadata().write(writer, instance.getMetadata());
}
public boolean writeContentMinimal(final com.dslplatform.json.JsonWriter writer, final io.activej.fs.tcp.RemoteFsResponses.InfoFinished instance) {
boolean hasWritten = false;
if (instance.getMetadata() != null) {
writer.writeByte((byte)'"'); writer.writeAscii(name_metadata); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
writer_metadata().write(writer, instance.getMetadata());
writer.writeByte((byte)','); hasWritten = true;
}
return hasWritten;
}
public io.activej.fs.tcp.RemoteFsResponses.InfoFinished read(final com.dslplatform.json.JsonReader reader) throws java.io.IOException {
if (reader.wasNull()) return null;
else if (reader.last() != '{') throw reader.newParseError("Expecting '{' for object start");
reader.getNextToken();
return readContent(reader);
}
public io.activej.fs.tcp.RemoteFsResponses.InfoFinished readContent(final com.dslplatform.json.JsonReader reader) throws java.io.IOException {
io.activej.fs.FileMetadata _metadata_ = null;
if (reader.last() == '}') {
return new io.activej.fs.tcp.RemoteFsResponses.InfoFinished(_metadata_);
}
switch(reader.fillName()) {
case 1713525568:
reader.getNextToken();
_metadata_ = reader_metadata().read(reader);
reader.getNextToken();
break;
default:
reader.getNextToken();
reader.skip();
}
while (reader.last() == ','){
reader.getNextToken();
switch(reader.fillName()) {
case 1713525568:
reader.getNextToken();
_metadata_ = reader_metadata().read(reader);
reader.getNextToken();
break;
default:
reader.getNextToken();
reader.skip();
}
}
if (reader.last() != '}') throw reader.newParseError("Expecting '}' for object end");
return new io.activej.fs.tcp.RemoteFsResponses.InfoFinished(_metadata_);
}
}
}