All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.coinapi.websocket.model._Book_DslJsonConverter Maven / Gradle / Ivy

package io.coinapi.websocket.model;

public class _Book_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.registerBinder(io.coinapi.websocket.model.Book.class, objectConverter);
		__dsljson.registerReader(io.coinapi.websocket.model.Book.class, objectConverter);
		__dsljson.registerWriter(io.coinapi.websocket.model.Book.class, objectConverter);
	}
	public final static class ObjectFormatConverter implements com.dslplatform.json.runtime.FormatConverter, com.dslplatform.json.JsonReader.BindObject {
		private final boolean alwaysSerialize;
		private final com.dslplatform.json.DslJson __dsljson;
		private com.dslplatform.json.JsonReader.ReadObject reader_asks;
		private com.dslplatform.json.JsonReader.ReadObject reader_asks() {
			if (reader_asks == null) {
				java.lang.reflect.Type manifest = io.coinapi.websocket.model.Asks.class;
				reader_asks = __dsljson.tryFindReader(manifest);
				if (reader_asks == 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_asks;
		}
		private com.dslplatform.json.JsonWriter.WriteObject writer_asks;
		private com.dslplatform.json.JsonWriter.WriteObject writer_asks() {
			if (writer_asks == null) {
				java.lang.reflect.Type manifest = io.coinapi.websocket.model.Asks.class;
				writer_asks = __dsljson.tryFindWriter(manifest);
				if (writer_asks == 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_asks;
		}
		private com.dslplatform.json.JsonReader.ReadObject reader_bids;
		private com.dslplatform.json.JsonReader.ReadObject reader_bids() {
			if (reader_bids == null) {
				java.lang.reflect.Type manifest = io.coinapi.websocket.model.Bids.class;
				reader_bids = __dsljson.tryFindReader(manifest);
				if (reader_bids == 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_bids;
		}
		private com.dslplatform.json.JsonWriter.WriteObject writer_bids;
		private com.dslplatform.json.JsonWriter.WriteObject writer_bids() {
			if (writer_bids == null) {
				java.lang.reflect.Type manifest = io.coinapi.websocket.model.Bids.class;
				writer_bids = __dsljson.tryFindWriter(manifest);
				if (writer_bids == 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_bids;
		}
		ObjectFormatConverter(com.dslplatform.json.DslJson __dsljson) {
			this.alwaysSerialize = !__dsljson.omitDefaults;
			this.__dsljson = __dsljson;
		}
		public io.coinapi.websocket.model.Book read(final com.dslplatform.json.JsonReader reader) throws java.io.IOException {
			if (reader.wasNull()) return null;
			return bind(reader, new io.coinapi.websocket.model.Book());
		}
		private static final byte[] quoted_snapshot = "\"snapshot\":".getBytes(utf8);
		private static final byte[] name_snapshot = "snapshot".getBytes(utf8);
		private static final byte[] quoted_type = ",\"type\":".getBytes(utf8);
		private static final byte[] name_type = "type".getBytes(utf8);
		private static final byte[] quoted_timeCoinApi = ",\"time_coinapi\":".getBytes(utf8);
		private static final byte[] name_timeCoinApi = "time_coinapi".getBytes(utf8);
		private static final byte[] quoted_bids = ",\"bids\":".getBytes(utf8);
		private static final byte[] name_bids = "bids".getBytes(utf8);
		private static final byte[] quoted_asks = ",\"asks\":".getBytes(utf8);
		private static final byte[] name_asks = "asks".getBytes(utf8);
		private static final byte[] quoted_timeExchange = ",\"time_exchange\":".getBytes(utf8);
		private static final byte[] name_timeExchange = "time_exchange".getBytes(utf8);
		private static final byte[] quoted_sequence = ",\"sequence\":".getBytes(utf8);
		private static final byte[] name_sequence = "sequence".getBytes(utf8);
		private static final byte[] quoted_symbolId = ",\"symbol_id\":".getBytes(utf8);
		private static final byte[] name_symbolId = "symbol_id".getBytes(utf8);
		public final void write(final com.dslplatform.json.JsonWriter writer, final io.coinapi.websocket.model.Book 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.coinapi.websocket.model.Book instance) {
			writer.writeAscii(quoted_snapshot);
			if (instance.getSnapshot() == null) writer.writeNull();
			else com.dslplatform.json.BoolConverter.serialize(instance.getSnapshot(), writer);
			writer.writeAscii(quoted_type);
			if (instance.getType() == null) writer.writeNull();
			else com.dslplatform.json.StringConverter.serialize(instance.getType(), writer);
			writer.writeAscii(quoted_timeCoinApi);
			if (instance.getTimeCoinApi() == null) writer.writeNull();
			else com.dslplatform.json.JavaTimeConverter.serialize(instance.getTimeCoinApi(), writer);
			writer.writeAscii(quoted_bids);
			if (instance.getBids() == null) writer.writeNull();
			else writer.serialize(instance.getBids(), writer_bids());
			writer.writeAscii(quoted_asks);
			if (instance.getAsks() == null) writer.writeNull();
			else writer.serialize(instance.getAsks(), writer_asks());
			writer.writeAscii(quoted_timeExchange);
			if (instance.getTimeExchange() == null) writer.writeNull();
			else com.dslplatform.json.JavaTimeConverter.serialize(instance.getTimeExchange(), writer);
			writer.writeAscii(quoted_sequence);
			if (instance.getSequence() == null) writer.writeNull();
			else com.dslplatform.json.NumberConverter.serialize(instance.getSequence(), writer);
			writer.writeAscii(quoted_symbolId);
			if (instance.getSymbolId() == null) writer.writeNull();
			else com.dslplatform.json.StringConverter.serialize(instance.getSymbolId(), writer);
		}
		public boolean writeContentMinimal(final com.dslplatform.json.JsonWriter writer, final io.coinapi.websocket.model.Book instance) {
			boolean hasWritten = false;
			if (instance.getSnapshot() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_snapshot); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				com.dslplatform.json.BoolConverter.serialize(instance.getSnapshot(), writer);
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getType() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_type); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				com.dslplatform.json.StringConverter.serialize(instance.getType(), writer);
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getTimeCoinApi() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_timeCoinApi); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				com.dslplatform.json.JavaTimeConverter.serialize(instance.getTimeCoinApi(), writer);
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getBids() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_bids); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				writer.serialize(instance.getBids(), writer_bids());
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getAsks() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_asks); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				writer.serialize(instance.getAsks(), writer_asks());
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getTimeExchange() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_timeExchange); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				com.dslplatform.json.JavaTimeConverter.serialize(instance.getTimeExchange(), writer);
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getSequence() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_sequence); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				com.dslplatform.json.NumberConverter.serialize(instance.getSequence(), writer);
				writer.writeByte((byte)','); hasWritten = true;
			}
			if (instance.getSymbolId() != null) {
				writer.writeByte((byte)'"'); writer.writeAscii(name_symbolId); writer.writeByte((byte)'"'); writer.writeByte((byte)':');
				com.dslplatform.json.StringConverter.serialize(instance.getSymbolId(), writer);
				writer.writeByte((byte)','); hasWritten = true;
			}
			return hasWritten;
		}
		public io.coinapi.websocket.model.Book bind(final com.dslplatform.json.JsonReader reader, final io.coinapi.websocket.model.Book instance) throws java.io.IOException {
			if (reader.last() != '{') throw reader.newParseError("Expecting '{' for object start");
			reader.getNextToken();
			bindContent(reader, instance);
			return instance;
		}
		public io.coinapi.websocket.model.Book readContent(final com.dslplatform.json.JsonReader reader) throws java.io.IOException {
			io.coinapi.websocket.model.Book instance = new io.coinapi.websocket.model.Book();
 			bindContent(reader, instance);
			return instance;
		}
		public void bindContent(final com.dslplatform.json.JsonReader reader, final io.coinapi.websocket.model.Book instance) throws java.io.IOException {
			if (reader.last() == '}') return;
			if (reader.fillNameWeakHash() != 880 || !reader.wasLastName(name_snapshot)) { bindSlow(reader, instance, 0); return; }
			reader.getNextToken();
			instance.setSnapshot(com.dslplatform.json.BoolConverter.NULLABLE_READER.read(reader));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 450 || !reader.wasLastName(name_type)) { bindSlow(reader, instance, 1); return; }
			reader.getNextToken();
			instance.setType(com.dslplatform.json.StringConverter.READER.read(reader));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 1265 || !reader.wasLastName(name_timeCoinApi)) { bindSlow(reader, instance, 2); return; }
			reader.getNextToken();
			if (reader.wasNull()) instance.setTimeCoinApi(null);
			else instance.setTimeCoinApi(com.dslplatform.json.JavaTimeConverter.deserializeDateTime(reader));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 418 || !reader.wasLastName(name_bids)) { bindSlow(reader, instance, 3); return; }
			reader.getNextToken();
			instance.setBids(reader.readCollection(reader_bids()));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 434 || !reader.wasLastName(name_asks)) { bindSlow(reader, instance, 4); return; }
			reader.getNextToken();
			instance.setAsks(reader.readCollection(reader_asks()));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 1361 || !reader.wasLastName(name_timeExchange)) { bindSlow(reader, instance, 5); return; }
			reader.getNextToken();
			if (reader.wasNull()) instance.setTimeExchange(null);
			else instance.setTimeExchange(com.dslplatform.json.JavaTimeConverter.deserializeDateTime(reader));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 857 || !reader.wasLastName(name_sequence)) { bindSlow(reader, instance, 6); return; }
			reader.getNextToken();
			instance.setSequence(com.dslplatform.json.NumberConverter.NULLABLE_INT_READER.read(reader));
			if (reader.getNextToken() == '}')  return;
			if (reader.last() != ',') throw reader.newParseError("Expecting ',' for other mandatory properties"); else reader.getNextToken();
			if (reader.fillNameWeakHash() != 962 || !reader.wasLastName(name_symbolId)) { bindSlow(reader, instance, 7); return; }
			reader.getNextToken();
			instance.setSymbolId(com.dslplatform.json.StringConverter.READER.read(reader));
			if (reader.getNextToken() != '}') {
				if (reader.last() == ',') {
					reader.getNextToken();
					reader.fillNameWeakHash();
					bindSlow(reader, instance, 8);
				}
				if (reader.last() != '}') throw reader.newParseError("Expecting '}' for object end");
			}
		}
		private void bindSlow(final com.dslplatform.json.JsonReader reader, final io.coinapi.websocket.model.Book instance, int index) throws java.io.IOException {
			switch(reader.getLastHash()) {
				case -115896057:
					reader.getNextToken();
					instance.setSymbolId(com.dslplatform.json.StringConverter.READER.read(reader));
					reader.getNextToken();
					break;
				case 1011085160:
					reader.getNextToken();
					instance.setSequence(com.dslplatform.json.NumberConverter.NULLABLE_INT_READER.read(reader));
					reader.getNextToken();
					break;
				case 962060108:
					reader.getNextToken();
					if (reader.wasNull()) instance.setTimeExchange(null);
					else instance.setTimeExchange(com.dslplatform.json.JavaTimeConverter.deserializeDateTime(reader));
					reader.getNextToken();
					break;
				case 62166707:
					reader.getNextToken();
					instance.setAsks(reader.readCollection(reader_asks()));
					reader.getNextToken();
					break;
				case -1573183479:
					reader.getNextToken();
					instance.setBids(reader.readCollection(reader_bids()));
					reader.getNextToken();
					break;
				case 1543856616:
					reader.getNextToken();
					if (reader.wasNull()) instance.setTimeCoinApi(null);
					else instance.setTimeCoinApi(com.dslplatform.json.JavaTimeConverter.deserializeDateTime(reader));
					reader.getNextToken();
					break;
				case 1361572173:
					reader.getNextToken();
					instance.setType(com.dslplatform.json.StringConverter.READER.read(reader));
					reader.getNextToken();
					break;
				case 715361165:
					reader.getNextToken();
					instance.setSnapshot(com.dslplatform.json.BoolConverter.NULLABLE_READER.read(reader));
					reader.getNextToken();
					break;
				default:
					reader.getNextToken();
					reader.skip();
			}
			while (reader.last() == ','){
				reader.getNextToken();
				switch(reader.fillName()) {
					case -115896057:
						reader.getNextToken();
						instance.setSymbolId(com.dslplatform.json.StringConverter.READER.read(reader));
						reader.getNextToken();
						break;
					case 1011085160:
						reader.getNextToken();
						instance.setSequence(com.dslplatform.json.NumberConverter.NULLABLE_INT_READER.read(reader));
						reader.getNextToken();
						break;
					case 962060108:
						reader.getNextToken();
						if (reader.wasNull()) instance.setTimeExchange(null);
						else instance.setTimeExchange(com.dslplatform.json.JavaTimeConverter.deserializeDateTime(reader));
						reader.getNextToken();
						break;
					case 62166707:
						reader.getNextToken();
						instance.setAsks(reader.readCollection(reader_asks()));
						reader.getNextToken();
						break;
					case -1573183479:
						reader.getNextToken();
						instance.setBids(reader.readCollection(reader_bids()));
						reader.getNextToken();
						break;
					case 1543856616:
						reader.getNextToken();
						if (reader.wasNull()) instance.setTimeCoinApi(null);
						else instance.setTimeCoinApi(com.dslplatform.json.JavaTimeConverter.deserializeDateTime(reader));
						reader.getNextToken();
						break;
					case 1361572173:
						reader.getNextToken();
						instance.setType(com.dslplatform.json.StringConverter.READER.read(reader));
						reader.getNextToken();
						break;
					case 715361165:
						reader.getNextToken();
						instance.setSnapshot(com.dslplatform.json.BoolConverter.NULLABLE_READER.read(reader));
						reader.getNextToken();
						break;
					default:
						reader.getNextToken();
						reader.skip();
				}
			}
			if (reader.last() != '}') throw reader.newParseError("Expecting '}' for object end");
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy