### Question:
RecordBuilderBase implements RecordBuilder<T> { protected static boolean isValidValue(Field f, Object value) { if (value != null) { return true; } Schema schema = f.schema(); Type type = schema.getType(); if (type == Type.NULL) { return true; } if (type == Type.UNION) { for (Schema s : schema.getTypes()) { if (s.getType() == Type.NULL) { return true; } } } return false; } protected  RecordBuilderBase(Schema schema, GenericData data); protected  RecordBuilderBase(RecordBuilderBase<T> other, GenericData data); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testIsValidValueWithPrimitives() { for (Type type : primitives) { Field f = new Field("f", Schema.create(type), null, null); Assert.assertTrue(RecordBuilderBase.isValidValue(f, new Object())); } for (Type type : nonNullPrimitives) { Field f = new Field("f", Schema.create(type), null, null); Assert.assertFalse(RecordBuilderBase.isValidValue(f, null)); } }
@Test public void testIsValidValueWithNullField() { Assert.assertTrue(RecordBuilderBase.isValidValue(new Field("f", Schema.create(Type.NULL), null, null), null)); }
@Test public void testIsValidValueWithUnion() { Schema unionWithoutNull = Schema .createUnion(Arrays.asList(Schema.create(Type.STRING), Schema.create(Type.BOOLEAN))); Assert.assertTrue(RecordBuilderBase.isValidValue(new Field("f", unionWithoutNull, null, null), new Object())); Assert.assertFalse(RecordBuilderBase.isValidValue(new Field("f", unionWithoutNull, null, null), null)); Schema unionWithNull = Schema.createUnion(Arrays.asList(Schema.create(Type.STRING), Schema.create(Type.NULL))); Assert.assertTrue(RecordBuilderBase.isValidValue(new Field("f", unionWithNull, null, null), new Object())); Assert.assertTrue(RecordBuilderBase.isValidValue(new Field("f", unionWithNull, null, null), null)); }