com.beans.observables.properties.ObservableLongProperty Maven / Gradle / Ivy
The newest version!
package com.beans.observables.properties;
import com.beans.LongProperty;
/**
*
* A long specialization of {@link ObservableProperty}.
* Provides methods to access using primitive types: {@link #getAsLong()}, {@link #setAsLong(long)}.
* Listeners can be attached to listen for changes of the value.
*
*
* Implements {@link #set(Long)} and {@link #get()} as proxy calls to {@link #setAsLong(long)}
* and {@link #getAsLong()} respectively.
*
*
* This property is not nullable.
*
*
* @since JavaBeans 1.0
*/
public abstract class ObservableLongProperty extends ObservablePropertyBase implements LongProperty {
protected ObservableLongProperty(boolean threadSafe) {
super(threadSafe);
}
/**
* {@inheritDoc}
*
* This call invokes any listeners which are added if it changes
* the value which is stored by the property.
*
*/
@Override
public abstract void setAsLong(long value);
@Override
public void set(Long value) {
if (value == null) {
// TODO: LOG?
setAsLong(0);
} else {
setAsLong(value);
}
}
@Override
public Long get() {
return getAsLong();
}
@Override
public String toString() {
return String.format("ObservableLongProperty [value=%d]", getAsLong());
}
}