/*
* Copyright (C) 2015 higherfrequencytrading.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see
Implementation example:
* class LongPair { long first, second; }
*
* enum LongPairArrayWriter implements BytesWriter<LongPair[]> {
* INSTANCE;
*
* @Override
* public long size(LongPair[] longPairs) {
* return longPairs.length * 16L;
* }
*
* @Override
* public void write(Bytes bytes, LongPair[] longPairs) {
* for (LongPair pair : longPairs) {
* bytes.writeLong(pair.first);
* bytes.writeLong(pair.second);
* }
* }
* }
*
* @param Implementation of this method should increment the {@code bytes}' {@linkplain * Bytes#position() position} by {@link #size(Object) size(e)}. The given object should * be written into these range between the initial {@code bytes}' position and the position * after this method call returns. Implementation of this method must not alter the * {@code bytes}' {@linkplain Bytes#limit() limit} and contents outside of the specified range. * * @param bytes the {@code Bytes} to write the given object to * @param e the object to serialize to the given bytes * @see BytesReader#read(Bytes, long) */ void write(@NotNull Bytes bytes, @NotNull E e); }