/** * @since 2.5 */ public PropertyNamingStrategy getPropertyNamingStrategy() { // arbitrary choice but let's do: return _serializationConfig.getPropertyNamingStrategy(); }
@Test public void propertyNamingStrategy() { PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy(); ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().propertyNamingStrategy(strategy).build(); assertSame(strategy, objectMapper.getSerializationConfig().getPropertyNamingStrategy()); assertSame(strategy, objectMapper.getDeserializationConfig().getPropertyNamingStrategy()); }
@Test public void propertyNamingStrategy() { PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy(); this.factory.setPropertyNamingStrategy(strategy); this.factory.afterPropertiesSet(); assertSame(strategy, this.factory.getObject().getSerializationConfig().getPropertyNamingStrategy()); assertSame(strategy, this.factory.getObject().getDeserializationConfig().getPropertyNamingStrategy()); }
/** * @since 2.5 */ public PropertyNamingStrategy getPropertyNamingStrategy() { // arbitrary choice but let's do: return _serializationConfig.getPropertyNamingStrategy(); }
/** * @since 2.5 */ public PropertyNamingStrategy getPropertyNamingStrategy() { // arbitrary choice but let's do: return _serializationConfig.getPropertyNamingStrategy(); }
/** * @since 2.5 */ public PropertyNamingStrategy getPropertyNamingStrategy() { // arbitrary choice but let's do: return _serializationConfig.getPropertyNamingStrategy(); }
/** * @since 2.5 */ public PropertyNamingStrategy getPropertyNamingStrategy() { // arbitrary choice but let's do: return _serializationConfig.getPropertyNamingStrategy(); }
public String getName(Field field) { String name = field.getName(); if (field.isAnnotationPresent(JsonProperty.class) && !"".equals(field.getAnnotation(JsonProperty.class).value())) { name = field.getAnnotation(JsonProperty.class).value(); } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) { AnnotationMap annotationMap = buildAnnotationMap(field.getDeclaredAnnotations()); AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(field.getDeclaringClass(), serializationConfig); AnnotatedField annotatedField = AnnotatedFieldBuilder.build(annotatedClass, field, annotationMap); name = serializationConfig.getPropertyNamingStrategy().nameForField(serializationConfig, annotatedField, name); } return name; }
@Override public String nameForSerialization(final BeanPropertyDefinition beanProperty) { SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); Optional<PropertyNamingStrategy> namingStrategy = Optional.fromNullable(serializationConfig.getPropertyNamingStrategy()); String newName = namingStrategy .transform(overTheWireName(beanProperty, serializationConfig)) .or(beanProperty.getName()); LOG.debug("Name '{}' renamed to '{}'", beanProperty.getName(), newName); return newName; }
@Override public String nameForSerialization(final BeanPropertyDefinition beanProperty) { SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); Optional<PropertyNamingStrategy> namingStrategy = Optional.fromNullable(serializationConfig.getPropertyNamingStrategy()); String newName = namingStrategy .transform(overTheWireName(beanProperty, serializationConfig)) .or(beanProperty.getName()); LOG.debug("Name '{}' renamed to '{}'", beanProperty.getName(), newName); return newName; }
@Override public String nameForSerialization(final BeanPropertyDefinition beanProperty) { SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); Optional<PropertyNamingStrategy> namingStrategy = Optional.fromNullable(serializationConfig.getPropertyNamingStrategy()); String newName = namingStrategy .transform(overTheWireName(beanProperty, serializationConfig)) .or(beanProperty.getName()); LOG.debug("Name '{}' renamed to '{}'", beanProperty.getName(), newName); return newName; }
/** * Extract name to be used by Katharsis from getter's name. It uses * {@link ResourceFieldNameTransformer#getMethodName(Method)}, {@link JsonProperty} annotation and * {@link PropertyNamingStrategy}. * * @param method method to extract name * @return method name */ public String getName(Method method) { String name = getMethodName(method); if (method.isAnnotationPresent(JsonProperty.class) && !"".equals(method.getAnnotation(JsonProperty.class).value())) { name = method.getAnnotation(JsonProperty.class).value(); } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) { Annotation[] declaredAnnotations = method.getDeclaredAnnotations(); AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations); int paramsLength = method.getParameterAnnotations().length; AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength]; for (int i = 0; i < paramsLength; i++) { AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]); paramAnnotations[i] = parameterAnnotationMap; } AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig); AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations); name = serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name); } return name; }
boolean writeEmptyCollections = include != Include.NON_DEFAULT && include != Include.NON_EMPTY; PropertyNamingStrategyBase namingStrategy = new PropertyNamingStrategyWrapper(serializerProvider.getConfig().getPropertyNamingStrategy());