uk.co.autotrader.traverson.conversion.ResourceConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of traverson4j-core Show documentation
Show all versions of traverson4j-core Show documentation
The kernel of traverson4j. This provides the main API for a client to traverse a Hypermedia REST service
The newest version!
package uk.co.autotrader.traverson.conversion;
import uk.co.autotrader.traverson.exception.ConversionException;
import java.io.InputStream;
/**
* Register instances via META-INF/services/uk.co.autotrader.traverson.conversion.ResourceConverter Service loader config
* Or register them via ResourceConversionService.addConverter()
* Classes implementing this should be thread safe
* @param return type
*/
public interface ResourceConverter {
/**
* @return Destination Class that this converter will support
*/
Class getDestinationType();
/**
* Should only ever throw {@link uk.co.autotrader.traverson.exception.ConversionException}
*
* @param resource An InputStream of the resource wanting to be converted. This class should close the inputStream, unless explicitly documented
* @param returnType the class for the returned object
* @throws ConversionException if the conversion fails
* @return instance of returnType
*/
T convert(InputStream resource, Class extends T> returnType);
}