@Override public String findPropertyDefaultValue(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop == null) { return null; } String str = prop.defaultValue(); // Since annotations do not allow nulls, need to assume empty means "none" return str.isEmpty() ? null : str; }
/** * The default value, or null if none exists. * * @return The default value, or null if none exists. */ public String getDefaultValue() { String defaultValue = null; try { if ((propertyInfo != null) && (!"".equals(propertyInfo.defaultValue()))) { defaultValue = propertyInfo.defaultValue(); } } catch (NoSuchMethodError e) { //"defaultValue" method was added at Jackson 2.5... defaultValue = null; } catch (IncompleteAnnotationException e) { //"defaultValue" method was added at Jackson 2.5... defaultValue = null; } return defaultValue; }
/** * The default value, or null if none exists. * * @return The default value, or null if none exists. */ public String getDefaultValue() { String defaultValue = null; try { if ((propertyInfo != null) && (!"".equals(propertyInfo.defaultValue()))) { defaultValue = propertyInfo.defaultValue(); } } catch (NoSuchMethodError e) { //"defaultValue" method was added at Jackson 2.5... defaultValue = null; } catch (IncompleteAnnotationException e) { //"defaultValue" method was added at Jackson 2.5... defaultValue = null; } return defaultValue; }
@Override public String findPropertyDefaultValue(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop == null) { return null; } String str = prop.defaultValue(); // Since annotations do not allow nulls, need to assume empty means "none" return str.isEmpty() ? null : str; }
@Override public String findPropertyDefaultValue(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop == null) { return null; } String str = prop.defaultValue(); // Since annotations do not allow nulls, need to assume empty means "none" return str.isEmpty() ? null : str; }
@Override public String findPropertyDefaultValue(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop == null) { return null; } String str = prop.defaultValue(); // Since annotations do not allow nulls, need to assume empty means "none" return str.isEmpty() ? null : str; }
@Override public String findPropertyDefaultValue(Annotated ann) { JsonProperty prop = _findAnnotation(ann, JsonProperty.class); if (prop == null) { return null; } String str = prop.defaultValue(); // Since annotations do not allow nulls, need to assume empty means "none" return str.isEmpty() ? null : str; }
public static Map<String, Object> getPropertyDefaultValues(Class<? extends PredicateBase> predicateClass) { HashMap<String, Object> defaultValueMap = new HashMap<>(); Constructor<?> constructor = getJsonCreatorConstructor(predicateClass); // get all parameter types Class<?>[] parameterTypes = constructor.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { // find the @JsonProperty annotation for each parameter Annotation[] annotations = constructor.getParameterAnnotations()[i]; Optional<Annotation> findJsonProperty = Arrays.asList(annotations).stream() .filter(annotation -> annotation.annotationType().equals(JsonProperty.class)).findAny(); if (! findJsonProperty.isPresent()) { continue; } // convert the defaultValue from the string to the parameter's type JsonProperty jsonProperty = (JsonProperty) findJsonProperty.get(); if (! jsonProperty.defaultValue().trim().isEmpty()) { defaultValueMap.put(jsonProperty.value(), objectMapper.convertValue(jsonProperty.defaultValue(), parameterTypes[i])); } } return defaultValueMap; }