/** * Convenience method to return the value of a named field. This is the same as calling {@link #getField(String)}, * and using the returned value to call {@link #getFieldValue(Field)}. If the named field does not exist, this * method returns null. * * @param fieldName The name of the field whose value to return. * @return The value of the field, or null. */ public FieldValue getFieldValue(String fieldName) { Field field = getField(fieldName); if (field == null) { return null; } return getFieldValue(field); }
public static Object get(StructuredFieldValue struct, Field field) { return field == null ? null : unwrapValue(struct.getFieldValue(field)); }
private void setCorrectAnnotationReference(StructuredFieldValue struct, IdentityHashMap<Annotation, Integer> originalAnnotations, List<Annotation> newAnnotations) { for (Field f : struct.getDataType().getFields()) { setCorrectAnnotationReference(struct.getFieldValue(f), originalAnnotations, newAnnotations); } }
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; }
@Override protected void doExecute(ExecutionContext ctx) { FieldValue input = ctx.getValue(); if (!(input instanceof StructuredFieldValue)) { throw new IllegalArgumentException("Expected structured input, got " + input.getDataType().getName() + "."); } StructuredFieldValue struct = (StructuredFieldValue)input; Field field = struct.getField(fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in struct type '" + struct.getDataType().getName() + "'"); } ctx.setValue(struct.getFieldValue(field)); }
/** * 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; }
if (pos < fieldPath.size()) { if (fieldPath.get(pos).getType() == FieldPathEntry.Type.STRUCT_FIELD) { FieldValue fieldVal = getFieldValue(fieldPath.get(pos).getFieldRef()); if (fieldVal != null) { FieldPathIteratorHandler.ModificationStatus status = fieldVal.iterateNested(fieldPath, pos + 1, handler);