@Test public void testSetWithoutChange() throws Exception { GameEventListener theListener = mock(GameEventListener.class); Property<String> theProperty = new Property<String>(String.class, this, "property", "value", theListener); assertEquals("value", theProperty.get()); theProperty.set("value"); assertEquals("value", theProperty.get()); verifyZeroInteractions(theListener); }
public void set(T aValue) { if (aValue == value) { return; } if (value != null && value.equals(aValue)) { return; } if (aValue != null && aValue.equals(value)) { return; } if (value == null && aValue == null) { return; } T theOldValue = value; value = aValue; lastChanged = System.currentTimeMillis(); if (changeListener.length > 0) { PropertyChanged theEvent = new PropertyChanged(this, theOldValue); for (GameEventListener<PropertyChanged> theListener : changeListener) { theListener.handleGameEvent(theEvent); } } }
Property extends ReadOnlyProperty<T> { public void set(T aValue) { if (aValue == value) { return; } if (value != null && value.equals(aValue)) { return; } if (aValue != null && aValue.equals(value)) { return; } if (value == null && aValue == null) { return; } T theOldValue = value; value = aValue; lastChanged = System.currentTimeMillis(); if (changeListener.length > 0) { PropertyChanged theEvent = new PropertyChanged(this, theOldValue); for (GameEventListener<PropertyChanged> theListener : changeListener) { theListener.handleGameEvent(theEvent); } } } }
Property extends ReadOnlyProperty<T> { public void set(T aValue) { if (aValue == value) { return; } if (value != null && value.equals(aValue)) { return; } if (aValue != null && aValue.equals(value)) { return; } if (value == null && aValue == null) { return; } T theOldValue = value; value = aValue; lastChanged = System.currentTimeMillis(); if (changeListener.length > 0) { PropertyChanged theEvent = new PropertyChanged(this, theOldValue); for (GameEventListener<PropertyChanged> theListener : changeListener) { theListener.handleGameEvent(theEvent); } } } Property(Class<T> aType, Object aOwner, String aName, T aDefaultValue, GameEventListener<PropertyChanged> aListener);  Property(Class<T> aType, Object aOwner, String aName, GameEventListener<PropertyChanged> aListener);  Property(Class<T> aType, Object aOwner, String aName, T aDefaultValue); }
Property extends ReadOnlyProperty<T> { public void set(T aValue) { if (aValue == value) { return; } if (value != null && value.equals(aValue)) { return; } if (aValue != null && aValue.equals(value)) { return; } if (value == null && aValue == null) { return; } T theOldValue = value; value = aValue; lastChanged = System.currentTimeMillis(); if (changeListener.length > 0) { PropertyChanged theEvent = new PropertyChanged(this, theOldValue); for (GameEventListener<PropertyChanged> theListener : changeListener) { theListener.handleGameEvent(theEvent); } } } Property(Class<T> aType, Object aOwner, String aName, T aDefaultValue, GameEventListener<PropertyChanged> aListener);  Property(Class<T> aType, Object aOwner, String aName, GameEventListener<PropertyChanged> aListener);  Property(Class<T> aType, Object aOwner, String aName, T aDefaultValue); void set(T aValue); void setQuietly(T aValue); long getLastChanged(); List<GameEventListener<PropertyChanged>> getChangeListener(); void addChangeListener(GameEventListener<PropertyChanged> aListener); void removeChangeListener(GameEventListener<PropertyChanged> aListener); }
Property extends ReadOnlyProperty<T> { public void set(T aValue) { if (aValue == value) { return; } if (value != null && value.equals(aValue)) { return; } if (aValue != null && aValue.equals(value)) { return; } if (value == null && aValue == null) { return; } T theOldValue = value; value = aValue; lastChanged = System.currentTimeMillis(); if (changeListener.length > 0) { PropertyChanged theEvent = new PropertyChanged(this, theOldValue); for (GameEventListener<PropertyChanged> theListener : changeListener) { theListener.handleGameEvent(theEvent); } } } Property(Class<T> aType, Object aOwner, String aName, T aDefaultValue, GameEventListener<PropertyChanged> aListener);  Property(Class<T> aType, Object aOwner, String aName, GameEventListener<PropertyChanged> aListener);  Property(Class<T> aType, Object aOwner, String aName, T aDefaultValue); void set(T aValue); void setQuietly(T aValue); long getLastChanged(); List<GameEventListener<PropertyChanged>> getChangeListener(); void addChangeListener(GameEventListener<PropertyChanged> aListener); void removeChangeListener(GameEventListener<PropertyChanged> aListener);  }