SerializableCoder extends CustomCoder<T> { public static <T extends Serializable> SerializableCoder<T> of(TypeDescriptor<T> type) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) type.getRawType(); return new SerializableCoder<>(clazz, type); } protected  SerializableCoder(Class<T> type, TypeDescriptor<T> typeDescriptor); static SerializableCoder<T> of(TypeDescriptor<T> type); @Override boolean consistentWithEquals(); @Override Object structuralValue(T value); static SerializableCoder<T> of(Class<T> clazz); @SuppressWarnings("unused") static CoderProvider getCoderProvider(); Class<T> getRecordType(); @Override void encode(T value, OutputStream outStream); @Override T decode(InputStream inStream); @Override void verifyDeterministic(); @Override boolean equals(@Nullable Object other); @Override int hashCode(); @Override TypeDescriptor<T> getEncodedTypeDescriptor(); @Override String toString();  }
@Test public <T extends Serializable> void testSerializableCoderIsSerializableWithGenericTypeToken() throws Exception { SerializableCoder<T> coder = SerializableCoder.of(new TypeDescriptor<T>() {}); CoderProperties.coderSerializable(coder); }
@Test @Category(NeedsRunner.class) public void testDefaultCoder() throws Exception { p.enableAbandonedNodeEnforcement(true); PCollection<String> output = p.apply(Create.of("Hello", "World")) .apply(ParDo.of(new StringToRecord())) .apply(ParDo.of(new RecordToString())); PAssert.that(output).containsInAnyOrder("Hello", "World"); p.run(); }
@Test public void testNullEncoding() throws Exception { Coder<String> coder = SerializableCoder.of(String.class); byte[] encodedBytes = CoderUtils.encodeToByteArray(coder, null); assertNull(CoderUtils.decodeFromByteArray(coder, encodedBytes)); }
@Test public void coderChecksForEquals() throws Exception { SerializableCoder.of(ProperEquals.class); expectedLogs.verifyNotLogged("Can't verify serialized elements of type"); }