public void decr(final Attribute attr, final Object value) { _changes.put(attr.field.getName(), new Ternary<>(attr, false, value)); }
public void incr(final Attribute attr, final Object value) { _changes.put(attr.field.getName(), new Ternary<>(attr, true, value)); }
protected Attribute makeChange(final String field, final Object value) { final Attribute attr = _dao._allAttributes.get(field); assert (attr == null || attr.isUpdatable()) : "Updating an attribute that's not updatable: " + field; if (attr != null) { if (attr.attache == null) { _changes.put(field, new Ternary<>(attr, null, value)); } else { if (_collectionChanges == null) { _collectionChanges = new HashMap<>(); } _collectionChanges.put(attr, value); } } return attr; }
public void set(final Object entity, final Attribute attr, final Object value) { _changes.put(attr.field.getName(), new Ternary<>(attr, null, value)); try { attr.field.set(entity, value); } catch (final IllegalArgumentException e) { throw new CloudRuntimeException("Unable to update " + attr.field.getName() + " with " + value, e); } catch (final IllegalAccessException e) { throw new CloudRuntimeException("Unable to update " + attr.field.getName() + " with " + value, e); } }
@Test public void testEquals() { Assert.assertEquals(new Ternary<>("a", "b", "c"), new Ternary<>("a", "b", "c")); Assert.assertFalse(new Ternary<>("a", "b", "c").equals(new Ternary<>("a", "b", "d"))); Assert.assertFalse(new Ternary<>("a", "b", "c").equals("")); Assert.assertFalse(new Ternary<>("a", "b", "c").equals(null)); Assert.assertFalse(new Ternary<>("a", "b", "c").equals(new Pair<>("a", "b"))); } }