restx.endpoint.EndpointParamDef Maven / Gradle / Ivy
package restx.endpoint;
import java.util.Objects;
import restx.common.TypeReference;
import restx.factory.ParamDef;
/**
* Created by fcamblor on 07/02/15.
*/
public class EndpointParamDef extends ParamDef {
private final Endpoint endpoint;
public EndpointParamDef(String method, String pathPattern, TypeReference parameterType, String parameterName) {
this(Endpoint.of(method, pathPattern), parameterType, parameterName);
}
public EndpointParamDef(Endpoint endpoint, ParamDef paramDef) {
super(paramDef);
this.endpoint = endpoint;
}
public EndpointParamDef(Endpoint endpoint, TypeReference typeRef, String name) {
super(typeRef, name);
this.endpoint = endpoint;
}
public EndpointParamDef(Endpoint endpoint, Class primitiveType, String name) {
super(primitiveType, name);
this.endpoint = endpoint;
}
public Endpoint getEndpoint() {
return endpoint;
}
public static EndpointParamDef of(String method, String pathPattern, String parameterName, TypeReference parameterType) {
return new EndpointParamDef(method, pathPattern, parameterType, parameterName);
}
@Override
public String toString() {
return endpoint.toString() + " -> " + getType()+" "+getName();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof EndpointParamDef)) return false;
if (!super.equals(o)) return false;
EndpointParamDef> that = (EndpointParamDef>) o;
return Objects.equals(endpoint, that.endpoint);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), endpoint);
}
}