org.fugerit.java.dsb.DataService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of data-service-base Show documentation
Show all versions of data-service-base Show documentation
Simple data resources load/save interface layer.
package org.fugerit.java.dsb;
import java.io.IOException;
import java.io.InputStream;
/**
* Basic interface for saving/loading data.
*/
public interface DataService {
/**
* Retrieve saved data based on ID.
*
* @param id the id of the data to be loaded
* @return the data (null if the ID does not exists)
* @throws IOException if any I/O issue arises
*/
InputStream load( String id ) throws IOException;
/**
* Save data and assign an ID to it.
*
* @param data the data to be saved
* @return the ID assigned to saved data
* @throws IOException if any I/O issue arises
*/
String save( InputStream data ) throws IOException;
/**
* Save data and assign an ID to it.
*
* Default implementation of this method will invoke this.save( data )
*
* @param data the data to be saved
* @param resourceName resource name to be saved
* @return the ID assigned to saved data
* @throws IOException if any I/O issue arises
*/
default String save( InputStream data, String resourceName ) throws IOException {
return this.save( data );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy