All Downloads are FREE. Search and download functionalities are using the official Maven repository.

samplest.hello.FactoryInjectionResourceRouter Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
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 FactoryInjectionResourceRouter extends RestxRouter {

    public FactoryInjectionResourceRouter(
                    final FactoryInjectionResource resource,
                    final EntityRequestBodyReaderRegistry readerRegistry,
                    final EntityResponseWriterRegistry writerRegistry,
                    final MainStringConverter converter,
                    final PermissionFactory pf,
                    final Optional validator,
                    final RestxSecurityManager securityManager,
                    final EndpointParameterMapperRegistry paramMapperRegistry) {
        super(
            "default", "FactoryInjectionResourceRouter", new RestxRoute[] {
        new StdEntityRoute>("default#FactoryInjectionResource#testInterfaceSet",
                readerRegistry.build(Void.class, Optional.absent()),
                writerRegistry.>build(Types.newParameterizedType(java.util.Set.class, java.lang.String.class), Optional.absent()),
                Endpoint.of("GET", "/factory/interface/set"),
                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.testInterfaceSet(
                        
                    ));
                } catch(RuntimeException e) { throw e; }
                  catch(Exception e) { throw new WrappedCheckedException(e); }
            }

            @Override
            protected void describeOperation(OperationDescription operation) {
                super.describeOperation(operation);


                operation.responseClass = "Set";
                operation.inEntitySchemaKey = "";
                operation.inEntityType = Void.class;
                operation.outEntitySchemaKey = "";
                operation.outEntityType = Types.newParameterizedType(java.util.Set.class, java.lang.String.class);
                operation.sourceLocation = "samplest.hello.FactoryInjectionResource#testInterfaceSet()";
                operation.annotations = ImmutableList.builder()
                    .add(new restx.annotations.GET() {
                        public Class annotationType() { return restx.annotations.GET.class; }
                        public java.lang.String value() { return "/interface/set"; }
                    })
                    .build();
            }
        },
        new StdEntityRoute>("default#FactoryInjectionResource#testAbstractSet",
                readerRegistry.build(Void.class, Optional.absent()),
                writerRegistry.>build(Types.newParameterizedType(java.util.Set.class, java.lang.String.class), Optional.absent()),
                Endpoint.of("GET", "/factory/abstract/set"),
                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.testAbstractSet(
                        
                    ));
                } catch(RuntimeException e) { throw e; }
                  catch(Exception e) { throw new WrappedCheckedException(e); }
            }

            @Override
            protected void describeOperation(OperationDescription operation) {
                super.describeOperation(operation);


                operation.responseClass = "Set";
                operation.inEntitySchemaKey = "";
                operation.inEntityType = Void.class;
                operation.outEntitySchemaKey = "";
                operation.outEntityType = Types.newParameterizedType(java.util.Set.class, java.lang.String.class);
                operation.sourceLocation = "samplest.hello.FactoryInjectionResource#testAbstractSet()";
                operation.annotations = ImmutableList.builder()
                    .add(new restx.annotations.GET() {
                        public Class annotationType() { return restx.annotations.GET.class; }
                        public java.lang.String value() { return "/abstract/set"; }
                    })
                    .build();
            }
        },
        });
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy