Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
samplest.hello.TypeNullableResourceRouter Maven / Gradle / Ivy
package samplest.hello;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.base.Optional;
import com.google.common.base.Suppliers;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableList;
import restx.types.Types;
import restx.types.TypeReference;
import restx.*;
import restx.entity.*;
import restx.http.*;
import restx.endpoint.*;
import restx.exceptions.WrappedCheckedException;
import restx.factory.*;
import restx.security.*;
import restx.security.PermissionFactory;
import restx.description.*;
import restx.converters.MainStringConverter;
import static restx.common.MorePreconditions.checkPresent;
import jakarta.validation.Validator;
import static restx.validation.Validations.checkValid;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
@Component(priority = 0)
public class TypeNullableResourceRouter extends RestxRouter {
public TypeNullableResourceRouter(
final TypeNullableResource resource,
final EntityRequestBodyReaderRegistry readerRegistry,
final EntityResponseWriterRegistry writerRegistry,
final MainStringConverter converter,
final PermissionFactory pf,
final Optional validator,
final RestxSecurityManager securityManager,
final EndpointParameterMapperRegistry paramMapperRegistry) {
super(
"default", "TypeNullableResourceRouter", new RestxRoute[] {
new StdEntityRoute("default#TypeNullableResource#intNumberKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.Integer.class, Optional.absent()),
Endpoint.of("GET", "/int-number-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.intNumberKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "int";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.Integer.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#intNumberKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/int-number-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#longNumberKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.Long.class, Optional.absent()),
Endpoint.of("GET", "/long-number-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.longNumberKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "long";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.Long.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#longNumberKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/long-number-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#doubleNumberKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.Double.class, Optional.absent()),
Endpoint.of("GET", "/double-number-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.doubleNumberKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "double";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.Double.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#doubleNumberKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/double-number-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#floatNumberKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.Float.class, Optional.absent()),
Endpoint.of("GET", "/float-number-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.floatNumberKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "float";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.Float.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#floatNumberKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/float-number-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#byteKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.Byte.class, Optional.absent()),
Endpoint.of("GET", "/byte-number-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.byteKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "byte";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.Byte.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#byteKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/byte-number-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#booleanKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.Boolean.class, Optional.absent()),
Endpoint.of("GET", "/boolean-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.booleanKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "boolean";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.Boolean.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#booleanKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/boolean-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#stringNullableKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.String.class, Optional.absent()),
Endpoint.of("GET", "/string-nullable-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.fromNullable(resource.stringNullableKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "string";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.String.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#stringNullableKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/string-nullable-kt"; }
})
.add(new org.jetbrains.annotations.Nullable() {
public Class annotationType() { return org.jetbrains.annotations.Nullable.class; }
public java.lang.String value() { return ""; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#stringNonNullKotlin",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.String.class, Optional.absent()),
Endpoint.of("GET", "/string-non-null-kt"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.stringNonNullKotlin(
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
operation.responseClass = "string";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.String.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#stringNonNullKotlin()";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/string-non-null-kt"; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#query",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(java.lang.String.class, Optional.absent()),
Endpoint.of("GET", "/find-query-nullable-kotlin"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
ParamDef.of(new TypeReference(){}, "nullable"),
ParamDef.of(new TypeReference(){}, "optionalJ8"),
ParamDef.of(new TypeReference(){}, "optionalG"),
ParamDef.of(new TypeReference(){}, "nonNull")
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.fromNullable(resource.query(
/* [QUERY] nullable */ checkValid(validator, mapQueryObjectFromRequest(java.lang.String.class, "nullable", request, match, EndpointParameterKind.QUERY)),
/* [QUERY] optionalJ8 */ java.util.Optional.ofNullable(checkValid(validator, mapQueryObjectFromRequest(java.lang.String.class, "optionalJ8", request, match, EndpointParameterKind.QUERY))),
/* [QUERY] optionalG */ Optional.fromNullable(checkValid(validator, mapQueryObjectFromRequest(java.lang.String.class, "optionalG", request, match, EndpointParameterKind.QUERY))),
/* [QUERY] nonNull */ checkValid(validator, checkNotNull(mapQueryObjectFromRequest(java.lang.String.class, "nonNull", request, match, EndpointParameterKind.QUERY), "QUERY param is required"))
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
OperationParameterDescription nullable = new OperationParameterDescription();
nullable.name = "nullable";
nullable.paramType = OperationParameterDescription.ParamType.query;
nullable.dataType = "string";
nullable.schemaKey = "";
nullable.required = false;
operation.parameters.add(nullable);
OperationParameterDescription optionalJ8 = new OperationParameterDescription();
optionalJ8.name = "optionalJ8";
optionalJ8.paramType = OperationParameterDescription.ParamType.query;
optionalJ8.dataType = "string";
optionalJ8.schemaKey = "";
optionalJ8.required = false;
operation.parameters.add(optionalJ8);
OperationParameterDescription optionalG = new OperationParameterDescription();
optionalG.name = "optionalG";
optionalG.paramType = OperationParameterDescription.ParamType.query;
optionalG.dataType = "string";
optionalG.schemaKey = "";
optionalG.required = false;
operation.parameters.add(optionalG);
OperationParameterDescription nonNull = new OperationParameterDescription();
nonNull.name = "nonNull";
nonNull.paramType = OperationParameterDescription.ParamType.query;
nonNull.dataType = "string";
nonNull.schemaKey = "";
nonNull.required = true;
operation.parameters.add(nonNull);
operation.responseClass = "string";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "";
operation.outEntityType = java.lang.String.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#query(java.lang.String,java.util.Optional,com.google.common.base.Optional,java.lang.String)";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/find-query-nullable-kotlin"; }
})
.add(new org.jetbrains.annotations.Nullable() {
public Class annotationType() { return org.jetbrains.annotations.Nullable.class; }
public java.lang.String value() { return ""; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#queryNullableCriteria",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(samplest.hello.Criteria.class, Optional.absent()),
Endpoint.of("GET", "/find-nullable-criteria-kotlin"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
ParamDef.of(new TypeReference(){}, "criteria")
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.fromNullable(resource.queryNullableCriteria(
/* [QUERY] criteria */ checkValid(validator, mapQueryObjectFromRequest(samplest.hello.Criteria.class, "criteria", request, match, EndpointParameterKind.QUERY))
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
OperationParameterDescription criteria = new OperationParameterDescription();
criteria.name = "criteria";
criteria.paramType = OperationParameterDescription.ParamType.query;
criteria.dataType = "Criteria";
criteria.schemaKey = "samplest.hello.Criteria";
criteria.required = false;
operation.parameters.add(criteria);
operation.responseClass = "Criteria";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "samplest.hello.Criteria";
operation.outEntityType = samplest.hello.Criteria.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#queryNullableCriteria(samplest.hello.Criteria)";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/find-nullable-criteria-kotlin"; }
})
.add(new org.jetbrains.annotations.Nullable() {
public Class annotationType() { return org.jetbrains.annotations.Nullable.class; }
public java.lang.String value() { return ""; }
})
.build();
}
},
new StdEntityRoute("default#TypeNullableResource#queryCriteria",
readerRegistry.build(Void.class, Optional.absent()),
writerRegistry.build(samplest.hello.Criteria.class, Optional.absent()),
Endpoint.of("GET", "/find-criteria-kotlin"),
HttpStatus.OK, RestxLogLevel.DEFAULT, pf,
paramMapperRegistry, new ParamDef[]{
ParamDef.of(new TypeReference(){}, "criteria")
}) {
@Override
protected Optional doRoute(RestxRequest request, RestxResponse response, RestxRequestMatch match, Void body) throws IOException {
securityManager.check(request, match, isAuthenticated());
try {
return Optional.of(resource.queryCriteria(
/* [QUERY] criteria */ checkValid(validator, checkNotNull(mapQueryObjectFromRequest(samplest.hello.Criteria.class, "criteria", request, match, EndpointParameterKind.QUERY), "QUERY param is required"))
));
} catch(RuntimeException e) { throw e; }
catch(Exception e) { throw new WrappedCheckedException(e); }
}
@Override
protected void describeOperation(OperationDescription operation) {
super.describeOperation(operation);
OperationParameterDescription criteria = new OperationParameterDescription();
criteria.name = "criteria";
criteria.paramType = OperationParameterDescription.ParamType.query;
criteria.dataType = "Criteria";
criteria.schemaKey = "samplest.hello.Criteria";
criteria.required = true;
operation.parameters.add(criteria);
operation.responseClass = "Criteria";
operation.inEntitySchemaKey = "";
operation.inEntityType = Void.class;
operation.outEntitySchemaKey = "samplest.hello.Criteria";
operation.outEntityType = samplest.hello.Criteria.class;
operation.sourceLocation = "samplest.hello.TypeNullableResource#queryCriteria(samplest.hello.Criteria)";
operation.annotations = ImmutableList.builder()
.add(new restx.annotations.GET() {
public Class annotationType() { return restx.annotations.GET.class; }
public java.lang.String value() { return "/find-criteria-kotlin"; }
})
.build();
}
},
});
}
}