Java源码示例:jsinterop.base.JsPropertyMap
示例1
static JsPropertyMap<Object> of() {
return new JavaStringMap<>();
}
示例2
@Nullable
@JsProperty
public JsPropertyMap<?> getData();
示例3
/**
* Get an object of all property names and values.
*
* @return object of all property names and values
*/
public native <T> JsPropertyMap<T> getProperties();
示例4
public void testObject() {
this.injectUrlAndTest(() -> {
Object object = new View();
assertNotNull(object);
object.set(PARAM_CUSTOM_VALUE, 1d);
assertNotNull(object.get(PARAM_CUSTOM_VALUE));
assertEquals(1d, object.get(PARAM_CUSTOM_VALUE));
assertNotNull(object.getProperties().get(PARAM_CUSTOM_VALUE));
object.unset(PARAM_CUSTOM_VALUE);
assertNull(object.get(PARAM_CUSTOM_VALUE));
assertNull(object.getProperties().get(PARAM_CUSTOM_VALUE));
JsPropertyMap<java.lang.Object> properties = JsPropertyMap.of();
properties.set(PARAM_CUSTOM_VALUE, "new value");
object.setProperties(properties);
assertEquals("new value", object.get(PARAM_CUSTOM_VALUE));
assertEquals("new value", object.getProperties().get(PARAM_CUSTOM_VALUE));
object.setProperties(properties, true);
});
}
示例5
/**
* Sets a collection of key-value pairs. Note that this changes any existing properties
* and adds new ones (it does not remove any existing properties).
*
* @param properties properties to set
*/
public native <T> void setProperties(JsPropertyMap<T> properties);
示例6
/**
* Sets a collection of key-value pairs. Note that this changes any existing properties
* and adds new ones (it does not remove any existing properties).
*
* @param properties properties to set
* @param silent Update without triggering an event.
*/
public native <T> void setProperties(JsPropertyMap<T> properties, boolean silent);