Added ApplicationEvent handling and annotation-based extension mechanism.

This commit is contained in:
Jon Brisbin
2012-04-26 11:40:14 -05:00
parent 57caa05823
commit fe9e485d81
31 changed files with 987 additions and 41 deletions

View File

@@ -0,0 +1,43 @@
package org.springframework.data.rest.core.util;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
/**
* @author Jon Brisbin <jon@jbrisbin.com>
*/
public class RestHelper<T> {
public HttpStatus status;
public HttpHeaders headers = new HttpHeaders();
public T body;
private RestHelper(T body) {
this.body = body;
}
public static <T> RestHelper<T> resource(T body) {
return new RestHelper<T>(body);
}
public RestHelper<T> header(String key, String value) {
headers.add(key, value);
return this;
}
public RestHelper<T> status(HttpStatus status) {
this.status = status;
return this;
}
public HttpEntity<T> asHttpEntity() {
return new HttpEntity<T>(body, headers);
}
public ResponseEntity<T> asResponseEntity() {
return new ResponseEntity<T>(body, headers, status);
}
}