Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.yammer.dropwizard.jersey;
  
 
 
     private static class QueryParamInjectable extends AbstractHttpContextInjectable<Object> {
         private final MultivaluedParameterExtractor extractor;
         private final boolean decode;
 
         private QueryParamInjectable(MultivaluedParameterExtractor extractor,
                                      boolean decode) {
             this. = extractor;
             this. = decode;
         }
 
         @Override
         public Object getValue(HttpContext c) {
             try {
                 return .extract(c.getUriInfo().getQueryParameters());
             } catch (ExtractorContainerException e) {
                 throw new ParamException.QueryParamException(e.getCause(),
                                                              .getName(),
                                                              .getDefaultStringValue());
             }
         }
     }
 
     private static class OptionalExtractor implements MultivaluedParameterExtractor {
         private final MultivaluedParameterExtractor extractor;
 
         private OptionalExtractor(MultivaluedParameterExtractor extractor) {
             this. = extractor;
         }
 
         @Override
         public String getName() {
             return .getName();
         }
 
         @Override
         public String getDefaultStringValue() {
             return .getDefaultStringValue();
         }
 
         @Override
         public Object extract(MultivaluedMap<StringStringparameters) {
             return Optional.fromNullable(.extract(parameters));
         }
     }
 
     private final ProviderServices services;
 
         this. = services;
     }
 
     @Override
     public ComponentScope getScope() {
         return .;
     }
 
     @Override
     public Injectable<?> getInjectable(ComponentContext ic,
                                        QueryParam a,
                                        Parameter c) {
         if (isExtractable(c)) {
             final OptionalExtractor extractor = new OptionalExtractor(getFactory().get(unpack(c)));
             return new QueryParamInjectable(extractor, !c.isEncoded());
         }
         return null;
     }
 
     private boolean isExtractable(Parameter param) {
         return (param.getSourceName() != null) && !param.getSourceName().isEmpty() &&
                 param.getParameterClass().isAssignableFrom(Optional.class) &&
                 (param.getParameterType() instanceof ParameterizedType);
     }
    private Parameter unpack(Parameter param) {
        final Type typeParameter = ((ParameterizedTypeparam.getParameterType()).getActualTypeArguments()[0];
        return new Parameter(param.getAnnotations(),
                             param.getAnnotation(),
                             param.getSource(),
                             param.getSourceName(),
                             typeParameter,
                             (Class<?>) typeParameter,
                             param.isEncoded(),
                             param.getDefaultValue());
    }
        if ( == null) {
            final StringReaderFactory stringReaderFactory = new StringReaderFactory();
            stringReaderFactory.init();
            this. = new MultivaluedParameterExtractorFactory(stringReaderFactory);
        }
        return ;
    }
New to GrepCode? Check out our FAQ X