@Test public void encodeDecode() throws Exception { PutInvariantMediaOp op = new PutInvariantMediaOp(100, 1); byte[] data = op.encode(); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data)); assertEquals(Op.PUT_INVARIANT_MEDIA, dis.readByte()); PutInvariantMediaOp decoded = new PutInvariantMediaOp(dis); assertEquals(op, decoded); }
@Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_MEDIA); dos.writeLong(to); dos.writeInt(ripIndex); } os.flush(); return os.toByteArray(); }
PutInvariantMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_MEDIA); dos.writeLong(to); dos.writeInt(ripIndex); } os.flush(); return os.toByteArray(); } }
PutInvariantMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_MEDIA); dos.writeLong(to); dos.writeInt(ripIndex); } os.flush(); return os.toByteArray(); } PutInvariantMediaOp(DataInputStream dis);  PutInvariantMediaOp(long to, int ripIndex); }
PutInvariantMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_MEDIA); dos.writeLong(to); dos.writeInt(ripIndex); } os.flush(); return os.toByteArray(); } PutInvariantMediaOp(DataInputStream dis);  PutInvariantMediaOp(long to, int ripIndex); @Override byte[] encode(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
PutInvariantMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_INVARIANT_MEDIA); dos.writeLong(to); dos.writeInt(ripIndex); } os.flush(); return os.toByteArray(); } PutInvariantMediaOp(DataInputStream dis);  PutInvariantMediaOp(long to, int ripIndex); @Override byte[] encode(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final int ripIndex; final long to; }