@Setup public void setup() { swappedByteBuf = new SwappedByteBuf(Unpooled.directBuffer(8)); unsafeSwappedByteBuf = Unpooled.directBuffer(8).order(ByteOrder.LITTLE_ENDIAN); if (unsafeSwappedByteBuf.getClass().equals(SwappedByteBuf.class)) { throw new IllegalStateException("Should not use " + SwappedByteBuf.class.getSimpleName()); } }
@Override public ByteBuf order(ByteOrder endianness) { if (endianness == null) { throw new NullPointerException("endianness"); } if (endianness == order()) { return this; } SwappedByteBuf swapped = this.swapped; if (swapped == null) { this.swapped = swapped = new SwappedByteBuf(this); } return swapped; }
@Override public ByteBuf order(final ByteOrder byteOrder) { if (byteOrder == null) { throw new NullPointerException("endianness"); } if (byteOrder == this.order()) { return this; } SwappedByteBuf swapped = this.swapped; if (swapped == null) { swapped = (this.swapped = new SwappedByteBuf(this)); } return swapped; }