NullableCoder extends StructuredCoder<T> { public static <T> NullableCoder<T> of(Coder<T> valueCoder) { if (valueCoder instanceof NullableCoder) { return (NullableCoder<T>) valueCoder; } return new NullableCoder<>(valueCoder); } private  NullableCoder(Coder<T> valueCoder); static NullableCoder<T> of(Coder<T> valueCoder); Coder<T> getValueCoder(); @Override void encode(@Nullable T value, OutputStream outStream); @Override void encode(@Nullable T value, OutputStream outStream, Context context); @Override T decode(InputStream inStream); @Override @Nullable T decode(InputStream inStream, Context context); @Override List<Coder<T>> getCoderArguments(); @Override void verifyDeterministic(); @Override boolean consistentWithEquals(); @Override Object structuralValue(@Nullable T value); @Override void registerByteSizeObserver(@Nullable T value, ElementByteSizeObserver observer); @Override boolean isRegisterByteSizeObserverCheap(@Nullable T value); @Override TypeDescriptor<T> getEncodedTypeDescriptor();  }
@Test public void testCoderIsSerializableWithWellKnownCoderType() throws Exception { CoderProperties.coderSerializable(NullableCoder.of(GlobalWindow.Coder.INSTANCE)); }
@Test public void testSubcoderRecievesEntireStream() throws Exception { NullableCoder<String> coder = NullableCoder.of(new EntireStreamExpectingCoder()); CoderProperties.coderDecodeEncodeEqualInContext(coder, Context.OUTER, null); CoderProperties.coderDecodeEncodeEqualInContext(coder, Context.OUTER, "foo"); }
@Test public void testNestedNullableCoder() { NullableCoder<Double> coder = NullableCoder.of(DoubleCoder.of()); assertThat(NullableCoder.of(coder), theInstance(coder)); }