aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-10-19 14:54:33 +0300
committerDenis Anisimov <denis@vaadin.com>2016-10-25 10:19:36 +0300
commit63d218efc0ee5825633b4950e3355f4e8cc7bc29 (patch)
treeb43fc989aded9041b3894714105ce43385798064 /server/src/main
parent862270140d287aba33dce03dc963db4421ebeb1a (diff)
downloadvaadin-framework-63d218efc0ee5825633b4950e3355f4e8cc7bc29.tar.gz
vaadin-framework-63d218efc0ee5825633b4950e3355f4e8cc7bc29.zip
Fix setValue() methods behavior null argument value + javadocs
Change-Id: I0000c1caf7c129634473161fe4876931f3c8dabf
Diffstat (limited to 'server/src/main')
-rw-r--r--server/src/main/java/com/vaadin/data/HasValue.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractColorPicker.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractDateField.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractField.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractTextField.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/CheckBox.java18
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/RichTextArea.java19
-rw-r--r--server/src/main/java/com/vaadin/ui/Slider.java17
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java18
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java17
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java14
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java14
14 files changed, 130 insertions, 25 deletions
diff --git a/server/src/main/java/com/vaadin/data/HasValue.java b/server/src/main/java/com/vaadin/data/HasValue.java
index 7a8bc7c296..aa130344b2 100644
--- a/server/src/main/java/com/vaadin/data/HasValue.java
+++ b/server/src/main/java/com/vaadin/data/HasValue.java
@@ -80,6 +80,7 @@ public interface HasValue<V> extends Serializable {
* {@code true} if this event originates from the client,
* {@code false} otherwise.
*/
+
public ValueChangeEvent(Component component, HasValue<V> hasValue,
boolean userOriginated) {
super(hasValue);
@@ -141,7 +142,6 @@ public interface HasValue<V> extends Serializable {
@FunctionalInterface
public interface ValueChangeListener<V>
extends Consumer<ValueChangeEvent<V>>, Serializable {
-
@Deprecated
public static final Method VALUE_CHANGE_METHOD = ReflectTools
.findMethod(ValueChangeListener.class, "accept",
diff --git a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
index f256636845..a537df0b21 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
@@ -164,10 +164,12 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
/**
* Sets the selected color of this color picker. If the new color is not
- * equal to getValue(), fires a value change event.
+ * equal to getValue(), fires a {@link ValueChangeEvent}.
*
* @param color
* the new selected color, not null
+ * @throws NullPointerException
+ * if {@code color} is {@code null}
*/
@Override
public void setValue(Color color) {
diff --git a/server/src/main/java/com/vaadin/ui/AbstractDateField.java b/server/src/main/java/com/vaadin/ui/AbstractDateField.java
index 4735d155d9..c62c76ac9c 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractDateField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractDateField.java
@@ -484,6 +484,13 @@ public abstract class AbstractDateField extends AbstractField<LocalDate>
return value;
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent} .
+ *
+ * @param value
+ * the new value, may be {@code null}
+ */
@Override
public void setValue(LocalDate value) {
/*
diff --git a/server/src/main/java/com/vaadin/ui/AbstractField.java b/server/src/main/java/com/vaadin/ui/AbstractField.java
index 7d87053a22..c87a72e430 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractField.java
@@ -52,8 +52,8 @@ public abstract class AbstractField<T> extends AbstractComponent
implements HasValue<T>, HasRequired, Focusable {
@Deprecated
- private static final Method VALUE_CHANGE_METHOD = ReflectTools
- .findMethod(ValueChangeListener.class, "accept", ValueChangeEvent.class);
+ private static final Method VALUE_CHANGE_METHOD = ReflectTools.findMethod(
+ ValueChangeListener.class, "accept", ValueChangeEvent.class);
@Override
public void setValue(T value) {
diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
index 5374b7d608..5ab6951f8d 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
@@ -366,7 +366,7 @@ public abstract class AbstractMultiSelect<T>
*
* @param value
* the items to select, not {@code null}
- * @throws IllegalArgumentException
+ * @throws NullPointerException
* if the value is invalid
*/
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractTextField.java b/server/src/main/java/com/vaadin/ui/AbstractTextField.java
index 9c2720efd8..ee2ccc6604 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractTextField.java
@@ -79,9 +79,19 @@ public abstract class AbstractTextField extends AbstractField<String>
registerRpc(new AbstractTextFieldFocusAndBlurRpcImpl());
}
+ /**
+ * Sets the value of this text field. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is not null.
+ *
+ * @param value
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code value} is {@code null}
+ */
@Override
public void setValue(String value) {
- Objects.requireNonNull(value, "Null value not supported");
+ Objects.requireNonNull(value, "value cannot be null");
setValue(value, false);
}
diff --git a/server/src/main/java/com/vaadin/ui/CheckBox.java b/server/src/main/java/com/vaadin/ui/CheckBox.java
index c4bedbea0a..02d7b0db8b 100644
--- a/server/src/main/java/com/vaadin/ui/CheckBox.java
+++ b/server/src/main/java/com/vaadin/ui/CheckBox.java
@@ -17,6 +17,7 @@
package com.vaadin.ui;
import java.util.Collection;
+import java.util.Objects;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
@@ -115,21 +116,18 @@ public class CheckBox extends AbstractField<Boolean>
}
/**
- * Sets the value of this ComboBox. If the new value is not equal to
- * {@code getValue()}, fires a value change event. Throws
- * {@code IllegalArgumentException} if the value is null.
+ * Sets the value of this CheckBox. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
*
* @param value
- * the new value
- * @throws IllegalArgumentException
- * if the value is null
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code value} is {@code null}
*/
@Override
public void setValue(Boolean value) {
- if (value == null) {
- throw new IllegalArgumentException(
- "CheckBox value must not be null");
- }
+ Objects.requireNonNull(value, "CheckBox value must not be null");
super.setValue(value);
}
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index 9ebc035c12..5c40a744f7 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -548,6 +548,13 @@ public class ComboBox<T> extends AbstractSingleSelect<T> implements HasValue<T>,
this.filter = filter;
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}.
+ *
+ * @param value
+ * the new value, may be {@code null}
+ */
@Override
public void setValue(T value) {
getSelectionModel().setSelectedFromServer(value);
diff --git a/server/src/main/java/com/vaadin/ui/RichTextArea.java b/server/src/main/java/com/vaadin/ui/RichTextArea.java
index 545166d33a..96a639e285 100644
--- a/server/src/main/java/com/vaadin/ui/RichTextArea.java
+++ b/server/src/main/java/com/vaadin/ui/RichTextArea.java
@@ -16,6 +16,8 @@
package com.vaadin.ui;
+import java.util.Objects;
+
import org.jsoup.nodes.Element;
import com.vaadin.shared.ui.ValueChangeMode;
@@ -100,13 +102,20 @@ public class RichTextArea extends AbstractField<String>
return (RichTextAreaState) super.getState(markAsDirty);
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
+ *
+ * @param value
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code value} is {@code null}
+ */
@Override
public void setValue(String value) {
- if (value == null) {
- setValue("", false);
- } else {
- setValue(value, false);
- }
+ Objects.requireNonNull(value, "value cannot be null");
+ setValue(value, false);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/Slider.java b/server/src/main/java/com/vaadin/ui/Slider.java
index 99ab476e2a..397e33e7c3 100644
--- a/server/src/main/java/com/vaadin/ui/Slider.java
+++ b/server/src/main/java/com/vaadin/ui/Slider.java
@@ -17,6 +17,7 @@
package com.vaadin.ui;
import java.util.Collection;
+import java.util.Objects;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
@@ -289,6 +290,22 @@ public class Slider extends AbstractField<Double> {
getState().value = trimmedValue;
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
+ *
+ * @param value
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code value} is {@code null}
+ */
+ @Override
+ public void setValue(Double value) {
+ Objects.requireNonNull(value, "color cannot be null");
+ super.setValue(value);
+ }
+
@Override
public Double getValue() {
return getState().value;
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
index ed8b12f80b..2e0b855ef9 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui.components.colorpicker;
+import java.util.Objects;
+
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerGradientServerRpc;
import com.vaadin.shared.ui.colorpicker.ColorPickerGradientState;
@@ -64,6 +66,22 @@ public class ColorPickerGradient extends AbstractField<Color> {
this.converter = converter;
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
+ *
+ * @param color
+ * the new color, not {@code null}
+ * @throws NullPointerException
+ * if {@code color} is {@code null}
+ */
+ @Override
+ public void setValue(Color color) {
+ Objects.requireNonNull(color, "value must not be null");
+ super.setValue(color);
+ }
+
@Override
public Color getValue() {
return color;
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
index c03c865d6d..95229a2d6a 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
@@ -18,6 +18,7 @@ package com.vaadin.ui.components.colorpicker;
import java.awt.Point;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerGridServerRpc;
@@ -174,6 +175,22 @@ public class ColorPickerGrid extends AbstractField<Color> {
return new int[] { x, y };
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
+ *
+ * @param color
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code color} is {@code null}
+ */
+ @Override
+ public void setValue(Color color) {
+ Objects.requireNonNull(color, "value cannot be null");
+ super.setValue(color);
+ }
+
@Override
public Color getValue() {
return colorGrid[x][y];
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index 4cf79d862d..ba00773fec 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -458,11 +458,19 @@ public class ColorPickerPopup extends Window implements HasValue<Color> {
return history;
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
+ *
+ * @param color
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code color} is {@code null}
+ */
@Override
public void setValue(Color color) {
- if (color == null) {
- return;
- }
+ Objects.requireNonNull(color, "color cannot be null");
selectedColor = color;
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
index fd284b64b9..67724d134b 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
@@ -63,8 +63,19 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> {
setValue(color);
}
+ /**
+ * Sets the value of this object. If the new value is not equal to
+ * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws
+ * {@code NullPointerException} if the value is null.
+ *
+ * @param color
+ * the new value, not {@code null}
+ * @throws NullPointerException
+ * if {@code color} is {@code null}
+ */
@Override
public void setValue(Color color) {
+ Objects.requireNonNull(color, "color cannot be null");
this.color = color;
// Unregister listener
@@ -160,7 +171,8 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> {
}
oldValue = value;
- fireEvent(new ValueChangeEvent<>(this, event.isUserOriginated()));
+ fireEvent(
+ new ValueChangeEvent<>(this, event.isUserOriginated()));
}
} catch (NumberFormatException nfe) {