SolrUtils { public static void setField(SolrInputDocument document, String fieldname, Object value, boolean update, Modifier modifier) { if (update) { document.setField(fieldname, new SingletonMap<>(modifier.name().toLowerCase(), value)); } else { document.setField(fieldname, value); } }  static void setField(SolrInputDocument document, String fieldname, Object value,
            boolean update, Modifier modifier); static void setField(SolrInputDocument document, String fieldname, Object value,
            boolean update);  }
@Test public void testAddField() { String fieldname = "field"; String value = "value"; String idValue = "1"; String idFieldname = "id"; boolean update = false; SolrInputDocument document = new SolrInputDocument(); document.addField(idFieldname, idValue); SolrUtils.setField(document, fieldname, value, update); assertEquals(idValue, document.getFieldValue(idFieldname)); assertEquals(value, document.getFieldValue(fieldname)); }