restx.entity.EntityResponseWriterRegistry Maven / Gradle / Ivy
package restx.entity;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.base.Supplier;
import restx.factory.Component;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Set;
/**
* Date: 23/10/13
* Time: 09:53
*/
@Component
public class EntityResponseWriterRegistry {
private final EntityContentTypeResolver entityContentTypeResolver;
private final Iterable entityResponseWriterFactories;
public EntityResponseWriterRegistry(Iterable entityDefaultContentTypeProviders,
Iterable entityResponseWriterFactories) {
entityContentTypeResolver = new EntityContentTypeResolver(entityDefaultContentTypeProviders);
this.entityResponseWriterFactories = entityResponseWriterFactories;
}
@SuppressWarnings("unchecked")
public EntityResponseWriter build(final Type type, Optional contentType) {
String ct = entityContentTypeResolver.resolveContentType(type, contentType);
for (EntityResponseWriterFactory writerFactory : entityResponseWriterFactories) {
Optional extends EntityResponseWriter