Module com.gluonhq.connect
Package com.gluonhq.connect.provider
Class RestObjectDataWriterAndRemover<T>
- java.lang.Object
-
- com.gluonhq.connect.provider.BaseRestProvider
-
- com.gluonhq.connect.provider.RestObjectDataReader<T>
-
- com.gluonhq.connect.provider.RestObjectDataWriterAndRemover<T>
-
- All Implemented Interfaces:
ObjectDataReader<T>
,ObjectDataRemover<T>
,ObjectDataWriter<T>
public class RestObjectDataWriterAndRemover<T> extends RestObjectDataReader<T> implements ObjectDataWriter<T>, ObjectDataRemover<T>
-
-
Field Summary
-
Fields inherited from class com.gluonhq.connect.provider.RestObjectDataReader
targetClass
-
Fields inherited from class com.gluonhq.connect.provider.BaseRestProvider
CONTENT_TYPE_APPLICATION_JSON, CONTENT_TYPE_TEXT_PLAIN, dataSource
-
-
Constructor Summary
Constructors Constructor Description RestObjectDataWriterAndRemover(RestDataSource dataSource, OutputStreamOutputConverter<T> outputConverter, InputStreamInputConverter<T> inputConverter)
RestObjectDataWriterAndRemover(RestDataSource dataSource, Class<T> targetClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<T>
removeObject(GluonObservableObject<T> observable)
Removes the object and optionally returns an object.Optional<T>
writeObject(T object)
Writes the object and optionally returns one.-
Methods inherited from class com.gluonhq.connect.provider.RestObjectDataReader
newGluonObservableObject, readObject
-
Methods inherited from class com.gluonhq.connect.provider.BaseRestProvider
getRestDataSource
-
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
-
RestObjectDataWriterAndRemover
public RestObjectDataWriterAndRemover(RestDataSource dataSource, Class<T> targetClass)
-
RestObjectDataWriterAndRemover
public RestObjectDataWriterAndRemover(RestDataSource dataSource, OutputStreamOutputConverter<T> outputConverter, InputStreamInputConverter<T> inputConverter)
-
-
Method Detail
-
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
-
-