Search in sources :

Example 1 with MultiKey

use of org.apache.tapestry5.commons.util.MultiKey in project tapestry-5 by apache.

the class MessagesSourceImpl method getMessages.

public Messages getMessages(MessagesBundle bundle, ComponentResourceSelector selector) {
    MultiKey key = new MultiKey(bundle.getId(), selector);
    Messages result = messagesByBundleIdAndSelector.get(key);
    if (result == null) {
        result = buildMessages(bundle, selector);
        messagesByBundleIdAndSelector.put(key, result);
    }
    return result;
}
Also used : Messages(org.apache.tapestry5.commons.Messages) MultiKey(org.apache.tapestry5.commons.util.MultiKey)

Example 2 with MultiKey

use of org.apache.tapestry5.commons.util.MultiKey in project tapestry-5 by apache.

the class PropertyConduitSourceImpl method create.

public PropertyConduit create(Class rootClass, String expression) {
    assert rootClass != null;
    assert InternalCommonsUtils.isNonBlank(expression);
    MultiKey key = new MultiKey(rootClass, expression);
    PropertyConduit result = cache.get(key);
    if (result == null) {
        result = build(rootClass, expression);
        cache.put(key, result);
    }
    return result;
}
Also used : MultiKey(org.apache.tapestry5.commons.util.MultiKey) InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit)

Example 3 with MultiKey

use of org.apache.tapestry5.commons.util.MultiKey in project tapestry-5 by apache.

the class MultiKeyTest method comparison_against_self.

@Test
public void comparison_against_self() {
    MultiKey key = new MultiKey(1, 3, "foo");
    assertTrue(key.equals(key));
}
Also used : MultiKey(org.apache.tapestry5.commons.util.MultiKey) Test(org.testng.annotations.Test)

Example 4 with MultiKey

use of org.apache.tapestry5.commons.util.MultiKey in project tapestry-5 by apache.

the class MultiKeyTest method comparisons_against_other_keys.

@Test
public void comparisons_against_other_keys() {
    MultiKey key1 = new MultiKey(1, 3, "foo");
    MultiKey key2 = new MultiKey(1, 3, "foo");
    MultiKey key3 = new MultiKey(1, 3);
    MultiKey key4 = new MultiKey(1, 3, "bar");
    MultiKey key5 = new MultiKey(1, 3, "foo", "bar");
    assertEquals(key2, key1);
    assertFalse(key3.equals(key1));
    assertFalse(key4.equals(key1));
    assertFalse(key5.equals(key1));
}
Also used : MultiKey(org.apache.tapestry5.commons.util.MultiKey) Test(org.testng.annotations.Test)

Example 5 with MultiKey

use of org.apache.tapestry5.commons.util.MultiKey in project tapestry-5 by apache.

the class MultiKeyTest method same_values_same_hash_codes.

@Test
public void same_values_same_hash_codes() {
    MultiKey key1 = new MultiKey(1, 3, "foo");
    MultiKey key2 = new MultiKey(1, 3, "foo");
    MultiKey key3 = new MultiKey(1, 3);
    MultiKey key4 = new MultiKey(1, 3, "bar");
    MultiKey key5 = new MultiKey(1, 3, "foo", "bar");
    assertEquals(key2.hashCode(), key1.hashCode());
    assertFalse(key3.hashCode() == key1.hashCode());
    assertFalse(key4.hashCode() == key1.hashCode());
    assertFalse(key5.hashCode() == key1.hashCode());
}
Also used : MultiKey(org.apache.tapestry5.commons.util.MultiKey) Test(org.testng.annotations.Test)

Aggregations

MultiKey (org.apache.tapestry5.commons.util.MultiKey)8 Test (org.testng.annotations.Test)4 Resource (org.apache.tapestry5.commons.Resource)2 PropertyConduit (org.apache.tapestry5.beanmodel.PropertyConduit)1 InternalPropertyConduit (org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit)1 Messages (org.apache.tapestry5.commons.Messages)1 ComponentTemplate (org.apache.tapestry5.internal.parser.ComponentTemplate)1