
net.anthavio.httl.HttlResponseExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hatatitla Show documentation
Show all versions of hatatitla Show documentation
Compact but tweakable REST client library you have been dreaming of
The newest version!
package net.anthavio.httl;
import java.io.IOException;
/**
*
* @author martin.vanek
*
*/
public interface HttlResponseExtractor {
/**
* @return extracted body of SenderResponse
*/
public abstract T extract(HttlResponse response) throws IOException;
/**
* Aggregation of reponse and extracted body
*
*/
public static class ExtractedResponse {
private final HttlResponse response;
private final T body;
public ExtractedResponse(HttlResponse response, T payload) {
this.response = response;
this.body = payload;
}
/**
* @return Recieved response
*/
public HttlResponse getResponse() {
return response;
}
/**
* @return Extracted response body
*/
public T getBody() {
return body;
}
@Override
public String toString() {
return String.valueOf(response + " " + body);
}
}
/*
public static class ReaderExtractor implements HttlResponseExtractor {
@Override
public ReaderExtractor supports(HttlResponse response) {
return this;
}
@Override
public Reader extract(HttlResponse response) throws IOException {
return response.getReader();
}
};
public static class StreamExtractor implements HttlResponseExtractor {
@Override
public StreamExtractor supports(HttlResponse response) {
return this;
}
@Override
public InputStream extract(HttlResponse response) throws IOException {
return response.getStream();
}
};
*/
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy