aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlli Tietäväinen <ollit@vaadin.com>2017-10-04 13:18:38 +0300
committerHenri Sara <henri.sara@gmail.com>2017-10-04 13:18:38 +0300
commit0eabcf3094dd81dbf15454145eec780130bc091c (patch)
tree38ae912b42d2646c52a20ff0693b76018e268f8e
parent83f5e593f66d36d99b22298e8023afd3c31a6122 (diff)
downloadvaadin-framework-0eabcf3094dd81dbf15454145eec780130bc091c.tar.gz
vaadin-framework-0eabcf3094dd81dbf15454145eec780130bc091c.zip
Support null intermediate properties in NestedMethodProperty (#10134)
Ignore null intermediate properties in setValue(). Forward port of #10085 in 7.7 to the compatibility package.
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java3
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java6
2 files changed, 9 insertions, 0 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
index 4228f04dcb..e9a24d040e 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
@@ -253,6 +253,9 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> {
Object object = instance;
for (int i = 0; i < getMethods.size() - 1; i++) {
object = getMethods.get(i).invoke(object);
+ if (object == null) {
+ return;
+ }
}
setMethod.invoke(object, new Object[] { value });
} catch (final InvocationTargetException e) {
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java
index 96065ae199..82e3fbb86a 100644
--- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java
+++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java
@@ -308,6 +308,12 @@ public class NestedMethodPropertyTest {
Address address2 = new Address("Other street", 12345);
addressProperty.setValue(address2);
assertEquals("Other street", streetProperty.getValue());
+
+ Address address3 = null;
+ addressProperty.setValue(address3);
+ assertEquals(null, addressProperty.getValue());
+ streetProperty.setValue("Ruukinkatu");
+ assertEquals(null, streetProperty.getValue());
}
@Test
ue='backport/29-openfile'>backport/29-openfile Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/AppFramework/Services/InitialStateProvider.php
blob: d1607bc2262cf9766dbcc086b9bad6cb46119466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCP\AppFramework\Services;

/**
 * @since 21.0.0
 */
abstract class InitialStateProvider implements \JsonSerializable {
	/**
	 * @since 21.0.0
	 */
	abstract public function getKey(): string;

	/**
	 * @since 21.0.0
	 */
	abstract public function getData();

	/**
	 * @since 21.0.0
	 * @return mixed
	 */
	#[\ReturnTypeWillChange]
	final public function jsonSerialize() {
		return $this->getData();
	}
}