Module com.gluonhq.cloudlink.client
Class GluonCloudObjectDataWriterImpl<T>
- java.lang.Object
-
- com.gluonhq.impl.cloudlink.client.data.GluonCloudObjectDataReaderImpl<T>
-
- com.gluonhq.impl.cloudlink.client.data.GluonCloudObjectDataWriterImpl<T>
-
- All Implemented Interfaces:
ObjectDataReader<T>
,ObjectDataRemover<T>
,ObjectDataWriter<T>
public class GluonCloudObjectDataWriterImpl<T> extends GluonCloudObjectDataReaderImpl<T> implements ObjectDataRemover<T>, ObjectDataWriter<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GluonCloudObjectDataWriterImpl.UsageType
-
Field Summary
-
Fields inherited from class com.gluonhq.impl.cloudlink.client.data.GluonCloudObjectDataReaderImpl
localObjectDataWriter, observable, operationMode
-
-
Constructor Summary
Constructors Constructor Description GluonCloudObjectDataWriterImpl(GluonObservableObjectImpl<T> observable, IncomingSseProcessor sseProcessor, OperationMode mode, UserClient userClient)
GluonCloudObjectDataWriterImpl(IncomingSseProcessor sseProcessor, OperationMode mode, UserClient userClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RestDataSource
createRestDataSource()
Optional<T>
removeObject(GluonObservableObject<T> observable)
Removes the object and optionally returns an object.void
setAlwaysCreate(boolean alwaysCreate)
Set to true when an update of an object should create the object if it does not yet exist.void
setListIdentifier(String listIdentifier)
void
setUsageType(GluonCloudObjectDataWriterImpl.UsageType usageType)
Optional<T>
writeObject(T object)
Writes the object and optionally returns one.-
Methods inherited from class com.gluonhq.impl.cloudlink.client.data.GluonCloudObjectDataReaderImpl
newGluonObservableObject, readJsonObject, readObject, unmarshallObject
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.gluonhq.connect.provider.ObjectDataWriter
newGluonObservableObject
-
-
-
-
Constructor Detail
-
GluonCloudObjectDataWriterImpl
public GluonCloudObjectDataWriterImpl(GluonObservableObjectImpl<T> observable, IncomingSseProcessor sseProcessor, OperationMode mode, UserClient userClient)
-
GluonCloudObjectDataWriterImpl
public GluonCloudObjectDataWriterImpl(IncomingSseProcessor sseProcessor, OperationMode mode, UserClient userClient)
-
-
Method Detail
-
setAlwaysCreate
public void setAlwaysCreate(boolean alwaysCreate)
Set to true when an update of an object should create the object if it does not yet exist.- Parameters:
alwaysCreate
- set to true to create non-existing object when updating one, false otherwise
-
setUsageType
public void setUsageType(GluonCloudObjectDataWriterImpl.UsageType usageType)
-
setListIdentifier
public void setListIdentifier(String listIdentifier)
-
createRestDataSource
protected RestDataSource createRestDataSource() throws IOException
- Overrides:
createRestDataSource
in classGluonCloudObjectDataReaderImpl<T>
- Throws:
IOException
-
writeObject
public Optional<T> writeObject(T object) throws IOException
Description copied from interface:ObjectDataWriter
Writes the object and optionally returns one. The actual method that converts the object into serialized data and the source where this data is written to is completely left to the implementation. This method is called byDataProvider.storeObject(Object, ObjectDataWriter)
to initiate the actual write process. The returned object will be set on the final GluonObservableObject that is provided by this writer'sObjectDataWriter.newGluonObservableObject()
method. The returned object can be the same as the provided object or it can be a completely new object. An empty Optional can be returned as well, which is the same as returning the provided object.- Specified by:
writeObject
in interfaceObjectDataWriter<T>
- Parameters:
object
- the object to write- Returns:
- the object that will ultimately be set on the GluonObservableObject
- Throws:
IOException
- when an exception occurred during the write process
-
removeObject
public Optional<T> removeObject(GluonObservableObject<T> observable) throws IOException
Description copied from interface:ObjectDataRemover
Removes the object and optionally returns an object. The actual method that removes the object is completely left to the implementation. This method is called byDataProvider.removeObject(GluonObservableObject, ObjectDataRemover)
to initiate the actual removal process. If this method returns a non-empty Optional, the object that is contained in the Optional will be set on the providedobservable
object. Otherwise, the value of theobservable
object will be set tonull
. When the remove operation completed successfully, the state of the providedobservable
will be set toConnectState.REMOVED
.- Specified by:
removeObject
in interfaceObjectDataRemover<T>
- Parameters:
observable
- the observable object that needs to be removed- Returns:
- an optional containing an object that will ultimately be set on the provided GluonObservableObject
- Throws:
IOException
- when an exception occurred during the removal process
-
-