@Override public boolean serialize(final ByteBuffer buffer) { if (this.contents.size() > 65535) { return false; } buffer.putShort((short) this.contents.size()); for (int i = 0; i < this.contents.size(); ++i) { final Content contents_element = this.contents.get(i); final boolean contents_element_ok = contents_element.serialize(buffer); if (!contents_element_ok) { return false; } } if (this.contentsSelection != null) { buffer.put((byte) 1); final boolean contentsSelection_ok = this.contentsSelection.serialize(buffer); if (!contentsSelection_ok) { return false; } } else { buffer.put((byte) 0); } if (this.buyableContents.size() > 65535) { return false; } buffer.putShort((short) this.buyableContents.size()); for (int i = 0; i < this.buyableContents.size(); ++i) { final BuyableContent buyableContents_element = this.buyableContents.get(i); final boolean buyableContents_element_ok = buyableContents_element.serialize(buffer); if (!buyableContents_element_ok) { return false; } } return true; }