/** * Sets the value of the annotation. * * @param fieldValue the value to set * @throws UnsupportedOperationException if the annotation type does not allow this annotation to have values. */ public void setFieldValue(FieldValue fieldValue) { if (fieldValue == null) { value = null; return; } DataType type = getType().getDataType(); if (type != null && type.isValueCompatible(fieldValue)) { this.value = fieldValue; } else { String typeName = (type == null) ? "null" : type.getValueClass().getName(); throw new IllegalArgumentException("Argument is of wrong type, must be of type " + typeName + ", was " + fieldValue.getClass().getName()); } }
Class<?> valClass = getValueClass(); if (valClass != null) { Pair<Class<?>, Class<?>> key = new Pair<>(valClass, arg.getClass());
/** * 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; }