public static void serialize(final Writer writer, final Customer value) throws IOException { writer.write("{\"URI\":"); StringConverter.serialize(value.getURI(), writer); final String _name = value.getName(); if (_name.length() > 0) { writer.write(",\"name\":"); StringConverter.serialize(_name, writer); } writer.write(",\"profile\":"); ProfileManualOptJsonSerialization.serialize(writer, value.getProfile()); final List<Account> _accounts = value.getAccounts(); if (_accounts != null && !_accounts.isEmpty()) { writer.write(",\"accounts\":["); int _cnt = 0; final int _total = _accounts.size() - 1; for (; _cnt < _total; _cnt++) { AccountManualOptJsonSerialization.serialize(writer, _accounts.get(_cnt)); writer.write(','); } AccountManualOptJsonSerialization.serialize(writer, _accounts.get(_cnt)); writer.write(']'); } else if (_accounts != null) writer.write(",\"accounts\":[]"); writer.write('}'); }
public static Customer deserialize( final Reader reader, final char[] buffer, final int[] tokens, int nextToken, final ServiceLocator locator) throws IOException { String _uri = ""; long _id = 0L; String _name = ""; Profile _profile = new Profile(); ArrayList<Account> _accounts = null; if (nextToken == '}') return new Customer(_uri, _id, _name, _profile, _accounts, locator); int nameHash = ManualJson.fillName(reader, buffer, nextToken); nextToken = ManualJson.getNextToken(reader); if (nextToken == 'n') { if (reader.read() != 'u' || reader.read() != 'l' || reader.read() != 'l') throw new IOException("null value expected"); } else { switch (nameHash) { case 1: _uri = StringConverter.deserialize(reader, buffer, nextToken); nextToken = ManualJson.getNextToken(reader); break; case 25458: _id = NumberConverter.deserializeInt(reader, buffer, tokens, nextToken); nextToken = ManualJson.moveToNextToken(reader, tokens[0]); break; case 24614690: _name = StringConverter.deserialize(reader, buffer, nextToken); nextToken = ManualJson.getNextToken(reader); break; case 1120506290: if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = ManualJson.getNextToken(reader); _profile = ProfileManualOptJsonSerialization.deserialize(reader, buffer, tokens, nextToken); nextToken = ManualJson.getNextToken(reader); break; case -758926083: if (nextToken != '[') throw new IOException("Expecting '['"); nextToken = ManualJson.getNextToken(reader); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = ManualJson.getNextToken(reader); _accounts = new ArrayList<Account>(); _accounts.add( AccountManualOptJsonSerialization.deserialize(reader, buffer, tokens, nextToken)); while ((nextToken = ManualJson.getNextToken(reader)) == ',') { nextToken = ManualJson.getNextToken(reader); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = ManualJson.getNextToken(reader); _accounts.add( AccountManualOptJsonSerialization.deserialize(reader, buffer, tokens, nextToken)); } nextToken = ManualJson.getNextToken(reader); break; default: nextToken = ManualJson.skip(reader, buffer, tokens, nextToken); break; } } while (nextToken == ',') { nextToken = ManualJson.getNextToken(reader); nameHash = ManualJson.fillName(reader, buffer, nextToken); nextToken = ManualJson.getNextToken(reader); if (nextToken == 'n') { if (reader.read() == 'u' && reader.read() == 'l' && reader.read() == 'l') { nextToken = ManualJson.getNextToken(reader); continue; } throw new IOException("null value expected"); } else { switch (nameHash) { case 1: _uri = StringConverter.deserialize(reader, buffer, nextToken); nextToken = ManualJson.getNextToken(reader); break; case 25458: _id = NumberConverter.deserializeInt(reader, buffer, tokens, nextToken); nextToken = ManualJson.moveToNextToken(reader, tokens[0]); break; case 24614690: _name = StringConverter.deserialize(reader, buffer, nextToken); nextToken = ManualJson.getNextToken(reader); break; case 1120506290: _profile = ProfileManualOptJsonSerialization.deserialize(reader, buffer, tokens, nextToken); nextToken = ManualJson.getNextToken(reader); break; case -758926083: if (nextToken != '[') throw new IOException("Expecting '['"); nextToken = ManualJson.getNextToken(reader); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = ManualJson.getNextToken(reader); _accounts = new ArrayList<Account>(); _accounts.add( AccountManualOptJsonSerialization.deserialize(reader, buffer, tokens, nextToken)); while ((nextToken = ManualJson.getNextToken(reader)) == ',') { nextToken = ManualJson.getNextToken(reader); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = ManualJson.getNextToken(reader); _accounts.add( AccountManualOptJsonSerialization.deserialize(reader, buffer, tokens, nextToken)); } nextToken = ManualJson.getNextToken(reader); break; default: nextToken = ManualJson.skip(reader, buffer, tokens, nextToken); break; } } } if (nextToken != '}') { if (nextToken == -1) throw new IOException("Unexpected end of json in object Transaction"); else throw new IOException( "Expecting '}' at position " + ManualJson.positionInStream(reader) + ". Found " + (char) nextToken); } return new Customer(_uri, _id, _name, _profile, _accounts, locator); }
public static Customer deserialize(final JsonReaderOptimized reader, final ServiceLocator locator) throws IOException { String _uri = ""; long _id = 0L; String _name = ""; Profile _profile = new Profile(); ArrayList<Account> _accounts = null; if (reader.getNextToken() == '}') return new Customer(_uri, _id, _name, _profile, _accounts, locator); int nameHash = reader.fillName(); int nextToken = reader.getNextToken(); if (nextToken == 'n') { if (reader.read() != 'u' || reader.read() != 'l' || reader.read() != 'l') throw new IOException("null value expected"); } else { switch (nameHash) { case 1: _uri = reader.readString(); nextToken = reader.getNextToken(); break; case 25458: _id = Long.parseLong(reader.readShortValue()); nextToken = reader.moveToNextToken(); break; case 24614690: _name = reader.readString(); nextToken = reader.getNextToken(); break; case 1120506290: if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = reader.getNextToken(); _profile = ProfileManualOptJsonSerialization.deserialize(reader); nextToken = reader.getNextToken(); break; case -758926083: if (nextToken != '[') throw new IOException("Expecting '['"); nextToken = reader.getNextToken(); if (nextToken != '{') throw new IOException("Expecting '{'"); _accounts = new ArrayList<Account>(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); while ((nextToken = reader.getNextToken()) == ',') { nextToken = reader.getNextToken(); if (nextToken != '{') throw new IOException("Expecting '{'"); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); } nextToken = reader.getNextToken(); break; default: nextToken = reader.skip(); break; } } while (nextToken == ',') { nextToken = reader.getNextToken(); nameHash = reader.fillName(); nextToken = reader.getNextToken(); if (nextToken == 'n') { if (reader.read() == 'u' && reader.read() == 'l' && reader.read() == 'l') { nextToken = reader.getNextToken(); continue; } throw new IOException("null value expected"); } else { switch (nameHash) { case 1: _uri = reader.readString(); nextToken = reader.getNextToken(); break; case 25458: _id = Long.parseLong(reader.readShortValue()); nextToken = reader.moveToNextToken(); break; case 24614690: _name = reader.readString(); nextToken = reader.getNextToken(); break; case 1120506290: if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = reader.getNextToken(); _profile = ProfileManualOptJsonSerialization.deserialize(reader); nextToken = reader.getNextToken(); break; case -758926083: if (nextToken != '[') throw new IOException("Expecting '['"); nextToken = reader.getNextToken(); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = reader.getNextToken(); _accounts = new ArrayList<Account>(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); while ((nextToken = reader.getNextToken()) == ',') { nextToken = reader.getNextToken(); if (nextToken != '{') throw new IOException("Expecting '{'"); nextToken = reader.getNextToken(); _accounts.add(AccountManualOptJsonSerialization.deserialize(reader)); } nextToken = reader.getNextToken(); break; default: nextToken = reader.skip(); break; } } } if (nextToken != '}') { throw new IOException( "Expecting '}' at position " + reader.positionInStream() + ". Found " + (char) nextToken); } return new Customer(_uri, _id, _name, _profile, _accounts, locator); }