NullableCoder extends StructuredCoder<T> { @Override public T decode(InputStream inStream) throws IOException, CoderException { return decode(inStream, Context.NESTED); } 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 testDecodingError() throws Exception { thrown.expect(CoderException.class); thrown.expectMessage( equalTo("NullableCoder expects either a byte valued 0 (null) " + "or 1 (present), got 5")); InputStream input = new ByteArrayInputStream(new byte[] {5}); TEST_CODER.decode(input, Coder.Context.OUTER); }