public static RecordDataSchema.Field copyField(RecordDataSchema.Field originalField, DataSchema fieldSchemaToReplace)
  {
    RecordDataSchema.Field newField = new RecordDataSchema.Field(fieldSchemaToReplace);
    if (originalField.getAliases() != null)
    {
      newField.setAliases(originalField.getAliases(), new StringBuilder());
    }
    if (originalField.getDefault() != null)
    {
      newField.setDefault(originalField.getDefault());
    }
    if (originalField.getDoc() != null)
    {
      newField.setDoc(originalField.getDoc());
    }
    if (originalField.getName() != null)
    {
      newField.setName(originalField.getName(), new StringBuilder());
    }
    if (originalField.getOrder() != null)
    {
      newField.setOrder(originalField.getOrder());
    }
    if (originalField.getProperties() != null)
    {
      newField.setProperties(originalField.getProperties());
    }
    newField.setOptional(originalField.getOptional());
    return newField;
  }
@Test
  public void testCopyField() throws Exception
  {
    RecordDataSchema fooSchema = (RecordDataSchema) TestUtil.dataSchemaFromString(fooSchemaText);
    RecordDataSchema.Field field = fooSchema.getField("intField");
    // Use old field to do the exact copy
    RecordDataSchema.Field newField = CopySchemaUtil.copyField(field, field.getType());
    newField.setRecord(field.getRecord());
    // Copy result should appear to be the same
    Assert.assertEquals(field, newField);
  }