public static Object remove(StructuredFieldValue struct, Field field) { return field == null ? null : unwrapValue(struct.removeFieldValue(field)); }
/** * Convenience method to remove the value of a named field. This is the same as calling {@link #getField(String)}, * and using the returned value to call {@link #removeFieldValue(Field)}. If the named field does not exist, this * method returns null. * * @param fieldName The name of the field whose value to remove. * @return The previous value of the field, or null. */ public FieldValue removeFieldValue(String fieldName) { Field field = getField(fieldName); if (field == null) { return null; } return removeFieldValue(field); }
private boolean removeObsoleteReferencesFromStructuredType(StructuredFieldValue struct, Map<Annotation, Annotation> selectedAnnotations, boolean removeIfPresent) { for (Field f : struct.getDataType().getFields()) { FieldValue fValue = struct.getFieldValue(f); if (removeObsoleteReferencesFromFieldValue(fValue, selectedAnnotations, removeIfPresent)) { struct.removeFieldValue(f); } } return false; }
/** * Sets the value of the given field. The type of the value must match the type of this field, i.e. * <pre>field.getDataType().getValueClass().isAssignableFrom(value.getClass())</pre> must be true. * * @param field The field whose value to set. * @param value The value to set. * @return The previous value of the field, or null. * @throws IllegalArgumentException If the value is not compatible with the field. */ public FieldValue setFieldValue(Field field, FieldValue value) { if (value == null) { return removeFieldValue(field); } DataType type = field.getDataType(); if (!type.getValueClass().isAssignableFrom(value.getClass())) { FieldValue tmp = type.createFieldValue(); tmp.assign(value); value = tmp; } FieldValue ret = getFieldValue(field); doSetFieldValue(field, value); return ret; }
FieldPathIteratorHandler.ModificationStatus status = fieldVal.iterateNested(fieldPath, pos + 1, handler); if (status == FieldPathIteratorHandler.ModificationStatus.REMOVED) { removeFieldValue(fieldPath.get(pos).getFieldRef()); return FieldPathIteratorHandler.ModificationStatus.MODIFIED; } else { removeFieldValue(field);