Module com.gluonhq.connect
Package com.gluonhq.connect.provider
Class OutputStreamObjectDataWriter<T>
- java.lang.Object
-
- com.gluonhq.connect.provider.OutputStreamObjectDataWriter<T>
-
- Type Parameters:
T- the type of the object to write
- All Implemented Interfaces:
ObjectDataWriter<T>
public class OutputStreamObjectDataWriter<T> extends Object implements ObjectDataWriter<T>
A helper class that represents anObjectDataWriterthat writes an object by converting it with a specificOutputStreamOutputConverterand writing it to a specificOutputDataSource.
-
-
Constructor Summary
Constructors Constructor Description OutputStreamObjectDataWriter(OutputDataSource dataSource, OutputStreamOutputConverter<T> converter)Construct an instance that will use the specified data source to write the object to that is converted with the specified converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GluonObservableObject<T>newGluonObservableObject()Provide an instance of a GluonObservableObject.Optional<T>writeObject(T object)Writes the object to the specified data source and returns an Optional that contains the exact same object instance that was passed in.
-
-
-
Constructor Detail
-
OutputStreamObjectDataWriter
public OutputStreamObjectDataWriter(OutputDataSource dataSource, OutputStreamOutputConverter<T> converter)
Construct an instance that will use the specified data source to write the object to that is converted with the specified converter. The OutputStream of the OutputDataSource will be set on the Converter before calling itswritemethod.- Parameters:
dataSource- the data source where the converted object will be written toconverter- the converter that is used for converting the object to be written
-
-
Method Detail
-
newGluonObservableObject
public GluonObservableObject<T> newGluonObservableObject()
Description copied from interface:ObjectDataWriterProvide an instance of a GluonObservableObject. This method is called byDataProvider.storeObject(Object, ObjectDataWriter)to get a GluonObservableObject that will contain the actual object when the store operation has completed successfully. Most implementations will just return an instance of GluonObservableObject itself. Note that it is perfectly valid to return existing instances of GluonObservableObject.- Specified by:
newGluonObservableObjectin interfaceObjectDataWriter<T>- Returns:
- an instance of a GluonObservableObject
-
writeObject
public Optional<T> writeObject(T object) throws IOException
Writes the object to the specified data source and returns an Optional that contains the exact same object instance that was passed in. This implementation uses the specified converter to convert the providedobject. The OutputStream of the specified data source will be set on the converter, before calling thewritemethod on the converter.- Specified by:
writeObjectin 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
-
-