io.activej.fs.tcp._RemoteFsCommands$Copy_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 _RemoteFsCommands$Copy_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.RemoteFsCommands.Copy.class, objectConverter);
__dsljson.registerWriter(io.activej.fs.tcp.RemoteFsCommands.Copy.class, objectConverter);
}
public final static class ObjectFormatConverter implements com.dslplatform.json.runtime.FormatConverter {
private final boolean alwaysSerialize;
private final com.dslplatform.json.DslJson __dsljson;
public ObjectFormatConverter(com.dslplatform.json.DslJson __dsljson) {
this.alwaysSerialize = !__dsljson.omitDefaults;
this.__dsljson = __dsljson;
}
private static final byte[] quoted_name = "\"name\":".getBytes(utf8);
private static final byte[] name_name = "name".getBytes(utf8);
private static final byte[] quoted_target = ",\"target\":".getBytes(utf8);
private static final byte[] name_target = "target".getBytes(utf8);
public final void write(final com.dslplatform.json.JsonWriter writer, final io.activej.fs.tcp.RemoteFsCommands.Copy 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.RemoteFsCommands.Copy instance) {
writer.writeAscii(quoted_name);
if (instance.getName() == null) writer.writeNull();
else com.dslplatform.json.StringConverter.serialize(instance.getName(), writer);
writer.writeAscii(quoted_target);
if (instance.getTarget() == null) writer.writeNull();
else com.dslplatform.json.StringConverter.serialize(instance.getTarget(), writer);
}
public boolean writeContentMinimal(final com.dslplatform.json.JsonWriter writer, final io.activej.fs.tcp.RemoteFsCommands.Copy instance) {
boolean hasWritten = false;
if (instance.getName() != null) {
writer.writeByte((byte)'"'); writer.writeAscii(name_name); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
com.dslplatform.json.StringConverter.serialize(instance.getName(), writer);
writer.writeByte((byte)','); hasWritten = true;
}
if (instance.getTarget() != null) {
writer.writeByte((byte)'"'); writer.writeAscii(name_target); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
com.dslplatform.json.StringConverter.serialize(instance.getTarget(), writer);
writer.writeByte((byte)','); hasWritten = true;
}
return hasWritten;
}
public io.activej.fs.tcp.RemoteFsCommands.Copy 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.RemoteFsCommands.Copy readContent(final com.dslplatform.json.JsonReader reader) throws java.io.IOException {
java.lang.String _name_ = null;
java.lang.String _target_ = null;
if (reader.last() == '}') {
return new io.activej.fs.tcp.RemoteFsCommands.Copy(_name_, _target_);
}
switch(reader.fillName()) {
case -1925595674:
reader.getNextToken();
_name_ = com.dslplatform.json.StringConverter.READER.read(reader);
reader.getNextToken();
break;
case 845187144:
reader.getNextToken();
_target_ = com.dslplatform.json.StringConverter.READER.read(reader);
reader.getNextToken();
break;
default:
reader.getNextToken();
reader.skip();
}
while (reader.last() == ','){
reader.getNextToken();
switch(reader.fillName()) {
case -1925595674:
reader.getNextToken();
_name_ = com.dslplatform.json.StringConverter.READER.read(reader);
reader.getNextToken();
break;
case 845187144:
reader.getNextToken();
_target_ = com.dslplatform.json.StringConverter.READER.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.RemoteFsCommands.Copy(_name_, _target_);
}
}
}