@SuppressWarnings("deprecation") static <V extends ValueOption<V>> V update(V property, V newValue) { property.copyFrom(newValue); return property; }
@SuppressWarnings("deprecation") @Override public E set(int index, E element) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(); } E result = get(index); result.copyFrom(element); return result; }
@SuppressWarnings({ "rawtypes", "unchecked", "deprecation" }) @Override public final Object copyObject(Object o) { ValueOption<?> object = (ValueOption<?>) o; if (object == null || object.isNull()) { return null; } ValueOption copy = newObject(); copy.copyFrom(object); return copy; }
/** * Sets the specified value to this object only if the specified value is less than this object. However, if either * this object or the specified value represents {@code null}, this object will also turn to {@code null}. * @param other the target value */ public final void min(V other) { if (this == other) { return; } if (this.isNull() || other.isNull()) { setNull(); } else if (compareTo(other) > 0) { copyFrom(other); } }
/** * Sets the specified value to this object only if the specified value is greater than this object. However, if * either this object or the specified value represents {@code null}, this object will also turn to {@code null}. * @param other the target value */ public final void max(V other) { if (this == other) { return; } if (this.isNull() || other.isNull()) { setNull(); } else if (compareTo(other) < 0) { copyFrom(other); } } }