@Test public void serialize() throws Exception { Mock mock = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy/MM/dd")); mock.setMock("", "0", "", new DateOption(new Date(2012, 1, 2))); byte[] s0 = ser(mock); Mock r0 = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy/MM/dd")); des(r0, s0); assertThat(r0.apply(), is("left0right2012/01/02")); mock.setMock("LLLLLLLLLLLLLL", "0", "RRRRRRRRRRRRRR"); byte[] s2 = ser(mock); Mock r2 = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy/MM/dd")); des(r2, s2); assertThat(s0, is(s2)); }
public final String apply() { nameBuffer.clear(); for (int i = 0; i < formatters.length; i++) { Text text = formatters[i].representation; nameBuffer.append(text.getBytes(), 0, text.getLength()); } return nameBuffer.toString(); }
StringTemplate implements WritableRawComparable { public final String apply() { nameBuffer.clear(); for (int i = 0; i < formatters.length; i++) { Text text = formatters[i].representation; nameBuffer.append(text.getBytes(), 0, text.getLength()); } return nameBuffer.toString(); } }
StringTemplate implements WritableRawComparable { public final String apply() { nameBuffer.clear(); for (int i = 0; i < formatters.length; i++) { Text text = formatters[i].representation; nameBuffer.append(text.getBytes(), 0, text.getLength()); } return nameBuffer.toString(); } protected  StringTemplate(FormatSpec... specs); }
StringTemplate implements WritableRawComparable { public final String apply() { nameBuffer.clear(); for (int i = 0; i < formatters.length; i++) { Text text = formatters[i].representation; nameBuffer.append(text.getBytes(), 0, text.getLength()); } return nameBuffer.toString(); } protected  StringTemplate(FormatSpec... specs); abstract void set(Object object); final String apply(); @Override final void write(DataOutput out); @Override final void readFields(DataInput in); @Override final int getSizeInBytes(byte[] buf, int offset); @Override final int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); @Override final int compareTo(WritableRawComparable o); @Override final int hashCode(); @Override final boolean equals(Object obj); }
StringTemplate implements WritableRawComparable { public final String apply() { nameBuffer.clear(); for (int i = 0; i < formatters.length; i++) { Text text = formatters[i].representation; nameBuffer.append(text.getBytes(), 0, text.getLength()); } return nameBuffer.toString(); } protected  StringTemplate(FormatSpec... specs); abstract void set(Object object); final String apply(); @Override final void write(DataOutput out); @Override final void readFields(DataInput in); @Override final int getSizeInBytes(byte[] buf, int offset); @Override final int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); @Override final int compareTo(WritableRawComparable o); @Override final int hashCode(); @Override final boolean equals(Object obj); static final StringTemplate EMPTY; }