@Override public void write(ByteWriter writer, T array) { Preconditions.checkArgument(array != null, "null array"); final int length = this.getArrayLength(array); for (int i = 0; i < length; i++) LongEncoder.write(writer, this.integralType.upCast(this.getArrayElement(array, i))); writer.writeByte(END); }
@Override public void skip(ByteReader reader) { while (true) { final int first = reader.peek(); if (first == END) { reader.skip(1); break; } reader.skip(LongEncoder.decodeLength(first)); } }
@Override public T read(ByteReader reader) { final ArrayList<E> list = new ArrayList<>(); while (true) { final int first = reader.peek(); if (first == END) { reader.skip(1); break; } list.add(this.integralType.downCast(LongEncoder.read(reader))); } return this.createArray(list); }