@Test public void testClear() { builder.setMessage(TestAllTypes.newBuilder().setOptionalInt32(0).build()); assertNotEquals(TestAllTypes.getDefaultInstance(), builder.getMessage()); builder.clear(); assertSame(TestAllTypes.getDefaultInstance(), builder.getMessage()); builder.getBuilder().setField(OPTIONAL_INT32, 1); assertNotEquals(TestAllTypes.getDefaultInstance(), builder.getMessage()); builder.clear(); assertEquals(TestAllTypes.getDefaultInstance(), builder.getMessage()); }
@Override @SuppressWarnings("unchecked") public void clear() { message = (MType) (message != null ? message.getDefaultInstanceForType() : builder .getDefaultInstanceForType()); if (builder != null) { dispose(builder); builder = null; } onChanged(); }
SingleFieldBuilder implements BuilderParent, IFieldBuilder { @Override @SuppressWarnings("unchecked") public void clear() { message = (MType) (message != null ? message.getDefaultInstanceForType() : builder .getDefaultInstanceForType()); if (builder != null) { dispose(builder); builder = null; } onChanged(); } }
SingleFieldBuilder implements BuilderParent, IFieldBuilder { @Override @SuppressWarnings("unchecked") public void clear() { message = (MType) (message != null ? message.getDefaultInstanceForType() : builder .getDefaultInstanceForType()); if (builder != null) { dispose(builder); builder = null; } onChanged(); } SingleFieldBuilder(final MType message, final BuilderParent parent, final boolean isClean); }
SingleFieldBuilder implements BuilderParent, IFieldBuilder { @Override @SuppressWarnings("unchecked") public void clear() { message = (MType) (message != null ? message.getDefaultInstanceForType() : builder .getDefaultInstanceForType()); if (builder != null) { dispose(builder); builder = null; } onChanged(); } SingleFieldBuilder(final MType message, final BuilderParent parent, final boolean isClean); @Override BuilderParent getParent(); @Override void dispose(); @SuppressWarnings("unchecked") MType getMessage(); @Override MType build(); BType getBuilder(); @SuppressWarnings("unchecked") IType getMessageOrBuilder(); SingleFieldBuilder<MType, BType, IType> setMessage(final MType message); SingleFieldBuilder<MType, BType, IType> mergeFrom(final MType value); @Override @SuppressWarnings("unchecked") void clear(); @Override void markDirty(); @Override boolean isInitialized(); }
SingleFieldBuilder implements BuilderParent, IFieldBuilder { @Override @SuppressWarnings("unchecked") public void clear() { message = (MType) (message != null ? message.getDefaultInstanceForType() : builder .getDefaultInstanceForType()); if (builder != null) { dispose(builder); builder = null; } onChanged(); } SingleFieldBuilder(final MType message, final BuilderParent parent, final boolean isClean); @Override BuilderParent getParent(); @Override void dispose(); @SuppressWarnings("unchecked") MType getMessage(); @Override MType build(); BType getBuilder(); @SuppressWarnings("unchecked") IType getMessageOrBuilder(); SingleFieldBuilder<MType, BType, IType> setMessage(final MType message); SingleFieldBuilder<MType, BType, IType> mergeFrom(final MType value); @Override @SuppressWarnings("unchecked") void clear(); @Override void markDirty(); @Override boolean isInitialized();  }