From dda62594f56e12590c5a3517585ad529e2df5c56 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 24 Sep 2012 14:41:56 +0300 Subject: Return an empty collection instead of null from Validatable.getValidators() (#9723) --- server/src/com/vaadin/data/Validatable.java | 7 ++++--- server/src/com/vaadin/ui/AbstractField.java | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/com/vaadin/data/Validatable.java b/server/src/com/vaadin/data/Validatable.java index a454e6f821..724a688efb 100644 --- a/server/src/com/vaadin/data/Validatable.java +++ b/server/src/com/vaadin/data/Validatable.java @@ -59,11 +59,12 @@ public interface Validatable extends Serializable { /** *

- * Lists all validators currently registered for the object. If no - * validators are registered, returns null. + * Returns a collection of all validators currently registered for the + * object. The collection may be immutable and it may not be safe to call + * removeValidator for this object while iterating over it. *

* - * @return collection of validators or null + * @return A collection of validators */ public Collection getValidators(); diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index e7d6d9a4ec..7fc5252eee 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -776,15 +776,16 @@ public abstract class AbstractField extends AbstractComponent implements /** * Gets the validators of the field. * - * @return the Unmodifiable collection that holds all validators for the + * @return An unmodifiable collection that holds all validators for the * field. */ @Override public Collection getValidators() { - if (validators == null || validators.isEmpty()) { - return null; + if (validators == null) { + return Collections.emptyList(); + } else { + return Collections.unmodifiableCollection(validators); } - return Collections.unmodifiableCollection(validators); } /** -- cgit v1.2.3