org.openstack4j.core.transport.Handle Maven / Gradle / Ivy
package org.openstack4j.core.transport;
/**
* A handle which is used to visit entity handling conditions and to determine if the workflow is satisfied
*
* @author Jeremy Unruh
*
* @param
*/
public class Handle {
private final HttpResponse response;
private final Class returnType;
private final ExecutionOptions options;
private final boolean requiresVoidBodyHandling;
private T returnObject;
private boolean complete;
private Handle(HttpResponse response, Class returnType, ExecutionOptions options, boolean requiresVoidBodyHandling) {
this.response = response;
this.returnType = returnType;
this.options = options;
this.requiresVoidBodyHandling = requiresVoidBodyHandling;
}
static Handle create(HttpResponse response, Class returnType, ExecutionOptions options, boolean requiresVoidBodyHandling) {
return new Handle(response, returnType, options, requiresVoidBodyHandling);
}
/**
* Stops handling workflow and sets the resulting return object
*
* @param returnObject the return object
* @return the handle
*/
Handle complete(T returnObject) {
this.complete = true;
this.returnObject = returnObject;
return this;
}
/**
* Handler did not satisfy the conditions it was after so this method lets the workflow know to continue the visiting process
* to the next handler
*
* @return the handle
*/
Handle continueHandling() {
this.complete = false;
return this;
}
public T getReturnObject() {
return returnObject;
}
public boolean isComplete() {
return complete;
}
public HttpResponse getResponse() {
return response;
}
public Class getReturnType() {
return returnType;
}
public ExecutionOptions getOptions() {
return options;
}
public boolean isRequiresVoidBodyHandling() {
return requiresVoidBodyHandling;
}
}