Simplify some of the RDAP Action classes

Overriding getter methods to change values is a bit overkill when these values
are static (don't change based on internal state).

Just setting them in the base class' constructor is simpler.

Also, we can read the PATH of an Action based on the Annotation instead
returning it manually for each Action.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246135754
This commit is contained in:
guyben 2019-05-01 08:32:29 -07:00 committed by jianglai
parent 8a4407a9a1
commit 9f017edc2e
21 changed files with 81 additions and 204 deletions

View file

@ -76,17 +76,17 @@ import org.joda.time.DateTime;
*/
@Action(
service = Action.Service.PUBAPI,
path = RdapEntitySearchAction.PATH,
path = "/rdap/entities",
method = {GET, HEAD},
auth = Auth.AUTH_PUBLIC)
public class RdapEntitySearchAction extends RdapSearchActionBase {
public static final String PATH = "/rdap/entities";
@Inject @Parameter("fn") Optional<String> fnParam;
@Inject @Parameter("handle") Optional<String> handleParam;
@Inject @Parameter("subtype") Optional<String> subtypeParam;
@Inject public RdapEntitySearchAction() {}
@Inject public RdapEntitySearchAction() {
super("entity search", EndpointType.ENTITIES);
}
private enum QueryType {
FULL_NAME,
@ -108,21 +108,6 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
private static final String CONTACT_CURSOR_PREFIX = "c:";
private static final String REGISTRAR_CURSOR_PREFIX = "r:";
@Override
public String getHumanReadableObjectTypeName() {
return "entity search";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.ENTITIES;
}
@Override
public String getActionPath() {
return PATH;
}
/** Parses the parameters and calls the appropriate search function. */
@Override
public ImmutableMap<String, Object> getJsonObjectForResource(