From 314e9254ed188f71cc6d5250671e6d01727da63b Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Fri, 18 Nov 2011 08:50:34 +0000 Subject: [PATCH] #4426 avoid calling datasource.getValue() multiple times unnecessarily svn changeset:22058/svn branch:6.7 --- src/com/vaadin/data/util/PropertyFormatter.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/vaadin/data/util/PropertyFormatter.java b/src/com/vaadin/data/util/PropertyFormatter.java index 18e1890259..ae9b0d40d1 100644 --- a/src/com/vaadin/data/util/PropertyFormatter.java +++ b/src/com/vaadin/data/util/PropertyFormatter.java @@ -33,8 +33,9 @@ import com.vaadin.data.Property; * @since 5.3.0 */ @SuppressWarnings("serial") -public abstract class PropertyFormatter extends AbstractProperty implements Property.Viewer, - Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener { +public abstract class PropertyFormatter extends AbstractProperty implements + Property.Viewer, Property.ValueChangeListener, + Property.ReadOnlyStatusChangeListener { /** Datasource that stores the actual value. */ Property dataSource; @@ -146,10 +147,14 @@ public abstract class PropertyFormatter extends AbstractProperty implements Prop */ @Override public String toString() { - if (dataSource == null || dataSource.getValue() == null) { + if (dataSource == null) { + return null; + } + Object value = dataSource.getValue(); + if (value == null) { return null; } - return format(dataSource.getValue()); + return format(value); } /** Reflects the read-only status of the datasource. */ -- 2.39.5