public interface CharmObservable
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<java.lang.Throwable> |
exception
Holds the exception that was thrown when a synchronization operation failed.
|
javafx.beans.property.ReadOnlyObjectProperty<CharmObservable.State> |
state
Holds the current state of this observable.
|
Modifier and Type | Interface and Description |
---|---|
static class |
CharmObservable.State
The possible states a CharmObservable can be in during synchronization operations.
|
Modifier and Type | Method and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<java.lang.Throwable> |
exceptionProperty()
Holds the exception that was thrown when a synchronization operation failed.
|
java.lang.Throwable |
getException()
In case an exception occurred during processing, this method will
return the exception.
|
java.lang.String |
getIdentifier()
Returns the unique identifier that is associated with this instance.
|
CharmObservable.State |
getState()
Return the current state of this observable.
|
StorageWhere |
getStorageWhere()
Returns the system where this instance will be stored.
|
javafx.beans.property.ReadOnlyObjectProperty<CharmObservable.State> |
stateProperty()
Holds the current state of this observable.
|
void |
sync()
Performs a synchronization of this observable with the underlying storage system.
|
javafx.beans.property.ReadOnlyObjectProperty<CharmObservable.State> stateProperty
CharmObservableObject charmSample = storageService.retrieveObject("sample", Sample.class); charmSample.stateProperty().addListener((observable, oldState, newState) -> { if (newState == CharmObservable.State.INITIALIZED) { // the object was successfully retrieved if (charmSample.get() == null) { // object was not yet known in the storage system charmSample.set(new Sample("aSimpleSample")); charmSample.sync(); } else { // object was known Sample sample = charmSample.get() System.out.println("Sample retrieved: " + sample); } } else if (newState == CharmObservable.State.FAILED) { // something went wrong while retrieving the object if (charmSample.getException() != null) { charmSample.getException().printStackTrace(); } else { System.out.println("Failed to retrieve sample for unknown reason."); } } }
getState()
javafx.beans.property.ReadOnlyObjectProperty<java.lang.Throwable> exceptionProperty
getException()
CharmObservable.State getState()
javafx.beans.property.ReadOnlyObjectProperty<CharmObservable.State> stateProperty()
CharmObservableObject charmSample = storageService.retrieveObject("sample", Sample.class); charmSample.stateProperty().addListener((observable, oldState, newState) -> { if (newState == CharmObservable.State.INITIALIZED) { // the object was successfully retrieved if (charmSample.get() == null) { // object was not yet known in the storage system charmSample.set(new Sample("aSimpleSample")); charmSample.sync(); } else { // object was known Sample sample = charmSample.get() System.out.println("Sample retrieved: " + sample); } } else if (newState == CharmObservable.State.FAILED) { // something went wrong while retrieving the object if (charmSample.getException() != null) { charmSample.getException().printStackTrace(); } else { System.out.println("Failed to retrieve sample for unknown reason."); } } }
getState()
java.lang.Throwable getException()
null
will be returned.javafx.beans.property.ReadOnlyObjectProperty<java.lang.Throwable> exceptionProperty()
getException()
java.lang.String getIdentifier()
StorageWhere getStorageWhere()
void sync()