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;
}
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;
}
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));
}
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));
}
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());
}
Aggregations