@Test public void encodeDecode() throws Exception { SwapVariantOp op = new SwapVariantOp(new VariantSpan(100, 1), new VariantSpan(200, 1)); byte[] data = op.encode(); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data)); assertEquals(Op.SWAP, dis.readByte()); SwapVariantOp decoded = new SwapVariantOp(dis); assertEquals(op, decoded); }
@Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.SWAP); dos.writeLong(v1.start); dos.writeLong(v1.width); dos.writeLong(v2.start); dos.writeLong(v2.width); } os.flush(); return os.toByteArray(); }
SwapVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.SWAP); dos.writeLong(v1.start); dos.writeLong(v1.width); dos.writeLong(v2.start); dos.writeLong(v2.width); } os.flush(); return os.toByteArray(); } }
SwapVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.SWAP); dos.writeLong(v1.start); dos.writeLong(v1.width); dos.writeLong(v2.start); dos.writeLong(v2.width); } os.flush(); return os.toByteArray(); } SwapVariantOp(DataInputStream dis);  SwapVariantOp(VariantSpan v1, VariantSpan v2); }
SwapVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.SWAP); dos.writeLong(v1.start); dos.writeLong(v1.width); dos.writeLong(v2.start); dos.writeLong(v2.width); } os.flush(); return os.toByteArray(); } SwapVariantOp(DataInputStream dis);  SwapVariantOp(VariantSpan v1, VariantSpan v2); @Override byte[] encode(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
SwapVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.SWAP); dos.writeLong(v1.start); dos.writeLong(v1.width); dos.writeLong(v2.start); dos.writeLong(v2.width); } os.flush(); return os.toByteArray(); } SwapVariantOp(DataInputStream dis);  SwapVariantOp(VariantSpan v1, VariantSpan v2); @Override byte[] encode(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final VariantSpan v1; final VariantSpan v2; }