Search in sources :

Example 1 with ConstantPoolKey

use of com.vaadin.flow.internal.ConstantPoolKey in project flow by vaadin.

the class ConstantPoolTest method sameValue_sameId.

@Test
public void sameValue_sameId() {
    ConstantPoolKey reference = new ConstantPoolKey(Json.createObject());
    String constantId = constantPool.getConstantId(reference);
    constantPool.dumpConstants();
    String otherId = constantPool.getConstantId(new ConstantPoolKey(Json.createObject()));
    Assert.assertEquals(constantId, otherId);
    Assert.assertFalse(constantPool.hasNewConstants());
}
Also used : ConstantPoolKey(com.vaadin.flow.internal.ConstantPoolKey) Test(org.junit.Test)

Example 2 with ConstantPoolKey

use of com.vaadin.flow.internal.ConstantPoolKey in project flow by vaadin.

the class ConstantPoolTest method differentValue_differentId.

@Test
public void differentValue_differentId() {
    ConstantPoolKey reference = new ConstantPoolKey(Json.createObject());
    String constantId = constantPool.getConstantId(reference);
    constantPool.dumpConstants();
    String otherId = constantPool.getConstantId(new ConstantPoolKey(Json.createArray()));
    Assert.assertNotEquals(constantId, otherId);
    Assert.assertTrue(constantPool.hasNewConstants());
}
Also used : ConstantPoolKey(com.vaadin.flow.internal.ConstantPoolKey) Test(org.junit.Test)

Example 3 with ConstantPoolKey

use of com.vaadin.flow.internal.ConstantPoolKey in project flow by vaadin.

the class ElementListenerMap method updateEventSettings.

private void updateEventSettings(String eventType) {
    Map<String, ExpressionSettings> eventSettings = collectEventExpressions(eventType);
    JsonObject eventSettingsJson = JsonUtils.createObject(eventSettings, ExpressionSettings::toJson);
    ConstantPoolKey constantPoolKey = new ConstantPoolKey(eventSettingsJson);
    put(eventType, constantPoolKey);
}
Also used : JsonObject(elemental.json.JsonObject) ConstantPoolKey(com.vaadin.flow.internal.ConstantPoolKey)

Example 4 with ConstantPoolKey

use of com.vaadin.flow.internal.ConstantPoolKey in project flow by vaadin.

the class PolymerServerEventHandlersTest method extractParametersData.

private JreJsonArray extractParametersData(Method method) {
    ConstantPoolKey parametersData = (ConstantPoolKey) stateNode.getFeature(PolymerEventListenerMap.class).get(method.getName());
    assertNotNull(parametersData);
    JsonObject json = Json.createObject();
    parametersData.export(json);
    return json.get(parametersData.getId());
}
Also used : JsonObject(elemental.json.JsonObject) ConstantPoolKey(com.vaadin.flow.internal.ConstantPoolKey)

Example 5 with ConstantPoolKey

use of com.vaadin.flow.internal.ConstantPoolKey in project flow by vaadin.

the class TemplateMap method setModelDescriptor.

/**
 * Sets the descriptor of the model type used by this template.
 *
 * @param modelDescriptor
 *            the model descriptor to set, not <code>null</code>
 */
public void setModelDescriptor(ModelDescriptor<?> modelDescriptor) {
    assert modelDescriptor != null;
    assert !contains(NodeProperties.MODEL_DESCRIPTOR);
    this.modelDescriptor = modelDescriptor;
    put(NodeProperties.MODEL_DESCRIPTOR, new ConstantPoolKey(modelDescriptor.toJson()));
}
Also used : ConstantPoolKey(com.vaadin.flow.internal.ConstantPoolKey)

Aggregations

ConstantPoolKey (com.vaadin.flow.internal.ConstantPoolKey)6 JsonObject (elemental.json.JsonObject)3 Test (org.junit.Test)2 Element (com.vaadin.flow.dom.Element)1 MapPutChange (com.vaadin.flow.internal.change.MapPutChange)1 NodeChange (com.vaadin.flow.internal.change.NodeChange)1 ElementListenerMap (com.vaadin.flow.internal.nodefeature.ElementListenerMap)1 ArrayList (java.util.ArrayList)1