Class IdMaskParamConverters


  • public final class IdMaskParamConverters
    extends Object
    A collection of default implementations for JAX-RS 2 ParamConverter for converting query-, path-, matrix-, header-, cookie- and form-parameter. The JAX-RS dependency is optional so you have to add them to maven yourself if you want to use this class. The following modules are required:
    • javax.ws.rs:javax.ws.rs-api

    Tested with version 2.2.1 at the time of writing (2019).

    Of course you require a JAX-RS implementation like Jersey or Apache-CXF.

    Use this in a ParamConverterProvider like so:

     @Provider
     public static class MyParamConverterProvider implements ParamConverterProvider {
          Inject private IdMask<Long> idMask;
    
          @Override
          public <T> ParamConverter<T> getConverter(Class<T> aClass, Type type, Annotation[] annotations) {
              if (aClass.equals(MaskedLongId.class)) {
                  return (ParamConverter<T>) new IdMaskMaskedLongIdParamConverter(idMask);
              } else if (aClass.equals(Long.class)) {
                  return (ParamConverter<T>) new IdMaskLongIdParamConverter(idMask);
              }
              ...
          }
     }
     

    See here for more info: https://dzone.com/articles/using-parameter-converters-in-jax-rs

    • Constructor Detail

      • IdMaskParamConverters

        public IdMaskParamConverters()