public static Type fromJavaType(Object value) throws ParserException { if (value instanceof String) { return Type.STRING; } else if (value instanceof Short) { return Type.SHORT; } else if (value instanceof Byte) { return Type.BYTE; } else if (value instanceof Float) { return Type.FLOAT; } else if (value instanceof Long) { return Type.LONG; } else if (value instanceof Double) { return Type.DOUBLE; } else if (value instanceof Integer) { return Type.INTEGER; } else if (value instanceof Boolean) { return Type.BOOLEAN; } else if (value instanceof List) { return Type.ARRAY; } else if (value instanceof Map) { return Type.NESTED; } throw new ParserException("Unknown type " + value.getClass()); }
public static WrappedWebApplicationException of(WebApplicationException ex) { return of(ex, ex.getMessage()); }
public static WrappedWebApplicationException of(WebApplicationException ex, String message) { Response.Status status = Response.Status.fromStatusCode(ex.getResponse().getStatus()); return new WrappedWebApplicationException(status, message, ex); } }
public static void ensureUnique(Storable storable, Function<List<QueryParam>, Collection<? extends Storable>> listFn, List<QueryParam> queryParams) { Collection<? extends Storable> storables = listFn.apply(queryParams); Optional<Long> entities = storables.stream() .map(Storable::getId) .filter(x -> !x.equals(storable.getId())) .findAny(); if (entities.isPresent()) { throw new DuplicateEntityException("Entity with '" + queryParams + "' already exists"); } }
public static Type fromJavaType(Object value) throws ParserException { if(value instanceof String) { return Type.STRING; } else if (value instanceof Short) { return Type.SHORT; } else if (value instanceof Byte) { return Type.BYTE; } else if (value instanceof Float) { return Type.FLOAT; } else if (value instanceof Long) { return Type.LONG; } else if (value instanceof Double) { return Type.DOUBLE; } else if (value instanceof Integer) { return Type.INTEGER; } else if (value instanceof Boolean) { return Type.BOOLEAN; } else if (value instanceof byte[]) { return Type.BINARY; } else if (value instanceof InputStream) { return Type.BLOB; } else if (value instanceof List) { return Type.ARRAY; } else if (value instanceof Map) { return Type.NESTED; } throw new ParserException("Unknown type " + value.getClass()); }
public static WrappedWebApplicationException of(WebApplicationException ex) { return of(ex, ex.getMessage()); }
public static WrappedWebApplicationException of(WebApplicationException ex, String message) { Response.Status status = Response.Status.fromStatusCode(ex.getResponse().getStatus()); return new WrappedWebApplicationException(status, message, ex); } }
public static void ensureUnique(Storable storable, Function<List<QueryParam>, Collection<? extends Storable>> listFn, List<QueryParam> queryParams) { Collection<? extends Storable> storables = listFn.apply(queryParams); Optional<Long> entities = storables.stream() .map(Storable::getId) .filter(x -> !x.equals(storable.getId())) .findAny(); if (entities.isPresent()) { throw new DuplicateEntityException("Entity with '" + queryParams + "' already exists"); } }
public static Type fromJavaType(Object value) throws ParserException { if(value instanceof String) { return Type.STRING; } else if (value instanceof Short) { return Type.SHORT; } else if (value instanceof Byte) { return Type.BYTE; } else if (value instanceof Float) { return Type.FLOAT; } else if (value instanceof Long) { return Type.LONG; } else if (value instanceof Double) { return Type.DOUBLE; } else if (value instanceof Integer) { return Type.INTEGER; } else if (value instanceof Boolean) { return Type.BOOLEAN; } else if (value instanceof byte[]) { return Type.BINARY; } else if (value instanceof InputStream) { return Type.BLOB; } else if (value instanceof List) { return Type.ARRAY; } else if (value instanceof Map) { return Type.NESTED; } throw new ParserException("Unknown type " + value.getClass()); }
public static WrappedWebApplicationException of(WebApplicationException ex) { return of(ex, ex.getMessage()); }
public static WrappedWebApplicationException of(WebApplicationException ex, String message) { Response.Status status = Response.Status.fromStatusCode(ex.getResponse().getStatus()); return new WrappedWebApplicationException(status, message, ex); } }
public static Type fromJavaType(Class<?> clazz) throws ParserException { if (clazz.equals(String.class)) { return Type.STRING; } else if (clazz.equals(Short.class)) { return Type.SHORT; } else if (clazz.equals(Byte.class)) { return Type.BYTE; } else if (clazz.equals(Float.class)) { return Type.FLOAT; } else if (clazz.equals(Long.class)) { return Type.LONG; } else if (clazz.equals(Double.class)) { return Type.DOUBLE; } else if (clazz.equals(Integer.class)) { return Type.INTEGER; } else if (clazz.equals(Boolean.class)) { return Type.BOOLEAN; } else if (clazz.equals(List.class)) { return Type.ARRAY; } else if (clazz.equals(Map.class)) { return Type.NESTED; } throw new ParserException("Unknown type " + clazz); }
public static Type fromJavaType(Class<?> clazz) throws ParserException { if(clazz.equals(String.class)) { return Type.STRING; } else if (clazz.equals(Short.class)) { return Type.SHORT; } else if (clazz.equals(Byte.class)) { return Type.BYTE; } else if (clazz.equals(Float.class)) { return Type.FLOAT; } else if (clazz.equals(Long.class)) { return Type.LONG; } else if (clazz.equals(Double.class)) { return Type.DOUBLE; } else if (clazz.equals(Integer.class)) { return Type.INTEGER; } else if (clazz.equals(Boolean.class)) { return Type.BOOLEAN; } else if (clazz.equals(byte[].class)) { return Type.BINARY; } else if (clazz.equals(InputStream.class)) { return Type.BLOB; } else if (clazz.equals(List.class)) { return Type.ARRAY; } else if (clazz.equals(Map.class)) { return Type.NESTED; } throw new ParserException("Unknown type " + clazz); }
public static Type fromJavaType(Class<?> clazz) throws ParserException { if(clazz.equals(String.class)) { return Type.STRING; } else if (clazz.equals(Short.class)) { return Type.SHORT; } else if (clazz.equals(Byte.class)) { return Type.BYTE; } else if (clazz.equals(Float.class)) { return Type.FLOAT; } else if (clazz.equals(Long.class)) { return Type.LONG; } else if (clazz.equals(Double.class)) { return Type.DOUBLE; } else if (clazz.equals(Integer.class)) { return Type.INTEGER; } else if (clazz.equals(Boolean.class)) { return Type.BOOLEAN; } else if (clazz.equals(byte[].class)) { return Type.BINARY; } else if (clazz.equals(InputStream.class)) { return Type.BLOB; } else if (clazz.equals(List.class)) { return Type.ARRAY; } else if (clazz.equals(Map.class)) { return Type.NESTED; } throw new ParserException("Unknown type " + clazz); }