本文整理匯總了Java中com.fasterxml.jackson.databind.BeanProperty類的典型用法代碼示例。如果您正苦於以下問題:Java BeanProperty類的具體用法?Java BeanProperty怎麽用?Java BeanProperty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BeanProperty類屬於com.fasterxml.jackson.databind包,在下文中一共展示了BeanProperty類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: customizeSchema
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
Optional.ofNullable(property.getAnnotation(Password.class)).ifPresent(annotation -> {
if (annotation.title() != null) {
((StringSchema) jsonschema).setTitle(annotation.title());
}
if (annotation.pattern() != null) {
((StringSchema) jsonschema).setPattern(annotation.pattern());
}
if (annotation.minLenght() != 0) {
((StringSchema) jsonschema).setMinLength(annotation.minLenght());
}
if (annotation.maxLenght() != Integer.MAX_VALUE) {
((StringSchema) jsonschema).setMaxLength(annotation.maxLenght());
}
});
}
示例2: customizeSchema
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
TextField annotation = property.getAnnotation(TextField.class);
if (annotation != null) {
if (annotation.title() != null) {
((StringSchema) jsonschema).setTitle(annotation.title());
}
if (annotation.pattern() != null) {
((StringSchema) jsonschema).setPattern(annotation.pattern());
}
if (annotation.minLenght() != 0) {
((StringSchema) jsonschema).setMinLength(annotation.minLenght());
}
if (annotation.maxLenght() != Integer.MAX_VALUE) {
((StringSchema) jsonschema).setMaxLength(annotation.maxLenght());
}
}
}
示例3: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public JsonSerializer<?> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) throws JsonMappingException {
if (beanProperty != null) {
// System.err.println("beanProperty:" + beanProperty + " name:" + beanProperty.getName() + " type:" + beanProperty.getMember().getGenericType());
Class<A> clazz = annotation();
A anno = beanProperty.getAnnotation(clazz);
if (anno == null) {
anno = beanProperty.getContextAnnotation(clazz);
}
if (anno != null) {
try {
return this.create(clazz, anno, beanProperty);
}
catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
return serializerProvider.findValueSerializer(beanProperty.getType(), beanProperty);
}
return serializerProvider.findNullValueSerializer(beanProperty);
}
示例4: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
BeanProperty property) throws JsonMappingException
{
JsonFormat.Value format = findFormatOverrides(ctxt, property, handledType());
if (format != null) {
if (format.hasPattern()) {
final String pattern = format.getPattern();
final Locale locale = format.hasLocale() ? format.getLocale() : ctxt.getLocale();
DateTimeFormatter df;
if (locale == null) {
df = DateTimeFormatter.ofPattern(pattern);
} else {
df = DateTimeFormatter.ofPattern(pattern, locale);
}
//Issue #69: For instant serializers/deserializers we need to configure the formatter with
//a time zone picked up from JsonFormat annotation, otherwise serialization might not work
if (format.hasTimeZone()) {
df = df.withZone(format.getTimeZone().toZoneId());
}
return withDateFormat(df);
}
// any use for TimeZone?
}
return this;
}
示例5: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
/**
* Method called to finalize setup of this deserializer,
* after deserializer itself has been registered. This
* is needed to handle recursive and transitive dependencies.
*/
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
BeanProperty property) throws JsonMappingException {
JsonDeserializer<?> deser = _valueDeserializer;
TypeDeserializer typeDeser = _typeDeserializerForValue;
if (deser == null) {
deser = ctxt.findContextualValueDeserializer(_containerType.getContentType(), property);
}
if (typeDeser != null) {
typeDeser = typeDeser.forProperty(property);
}
if (deser == _valueDeserializer && typeDeser == _typeDeserializerForValue) {
return this;
}
return withResolved(typeDeser, deser);
}
示例6: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
BeanProperty property) throws JsonMappingException {
if (property != null) {
JsonFormat.Value format = ctxt.getAnnotationIntrospector().findFormat((Annotated) property.getMember());
if (format != null) {
if (format.hasPattern()) {
final String pattern = format.getPattern();
final Locale locale = format.hasLocale() ? format.getLocale() : ctxt.getLocale();
DateTimeFormatter df;
if (locale == null) {
df = DateTimeFormatter.ofPattern(pattern);
} else {
df = DateTimeFormatter.ofPattern(pattern, locale);
}
return withDateFormat(df);
}
// any use for TimeZone?
}
}
return this;
}
示例7: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
/**
* We need to resolve actual serializer once we know the context; specifically
* must know type of property being serialized.
* If not known
*/
@Override
public JsonSerializer<?> createContextual(SerializerProvider provider,
BeanProperty property)
throws JsonMappingException
{
/* If we have property, should be able to get actual polymorphic type
* information.
* May need to refine in future, in case nested types are used, since
* 'property' refers to field/method and main type, but contents of
* that type may also be resolved... in which case this would fail.
*/
if (property != null) {
return new PersistentCollectionSerializer(property, property.getType(),
_forceLazyLoading);
}
return this;
}
示例8: initialize
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public void initialize(Bootstrap<?> bootstrap)
{
final InjectableValues injectableValues = new InjectableValues()
{
@Override
public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance)
{
return null;
}
};
final ConfigurationFactoryFactory<? extends Configuration> configurationFactoryFactory = bootstrap.getConfigurationFactoryFactory();
ConfigurationFactoryFactory factoryFactory = new ConfigurationFactoryFactory()
{
@Override
public ConfigurationFactory create(Class klass, Validator validator, ObjectMapper objectMapper, String propertyPrefix)
{
objectMapper.setInjectableValues(injectableValues);
//noinspection unchecked
return configurationFactoryFactory.create(klass, validator, objectMapper, propertyPrefix);
}
};
//noinspection unchecked
bootstrap.setConfigurationFactoryFactory(factoryFactory);
}
示例9: optionalProperty
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public void optionalProperty(BeanProperty prop) throws JsonMappingException {
String jsonName = prop.getName();
String fieldName = prop.getMember().getName();
JavaType baseType = prop.getType();
Assert.notNull(baseType,
"Missing type for property '" + jsonName + "', field '" + fieldName + "'");
for (JavaType javaType : resolveAllTypes(baseType, typeFactory)) {
JsonSerializer<?> ser = getProvider().findValueSerializer(javaType, prop);
if (ser == null) {
return;
}
visitType(prop, jsonName, fieldName, javaType, ser);
}
}
示例10: findInjectableValue
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
@Override
public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) {
//if a container, get content type
JavaType type = forProperty.getType();
if (type.isCollectionLikeType() | type.isArrayType()){
type = type.getContentType();
}
//checking annotation catches properties with interface types
if (ObjBase.class.isAssignableFrom(type.getRawClass()) || forProperty.getMember().getAnnotated().isAnnotationPresent(Reference.class)){
try {
return super.findInjectableValue(valueId, ctxt, forProperty, beanInstance);
} catch (IllegalArgumentException e){
Object value = getValue(valueId, type);
return value;
}
} else {
return super.findInjectableValue(valueId, ctxt, forProperty, beanInstance);
}
}
示例11: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
JsonSerializer localJsonSerializer1 = this._valueSerializer;
if (localJsonSerializer1 == null)
{
if ((paramSerializerProvider.isEnabled(MapperFeature.USE_STATIC_TYPING)) || (Modifier.isFinal(this._accessorMethod.getReturnType().getModifiers())))
{
JavaType localJavaType = paramSerializerProvider.constructType(this._accessorMethod.getGenericReturnType());
JsonSerializer localJsonSerializer2 = paramSerializerProvider.findTypedValueSerializer(localJavaType, false, this._property);
return withResolved(paramBeanProperty, localJsonSerializer2, isNaturalTypeWithStdHandling(localJavaType.getRawClass(), localJsonSerializer2));
}
}
else if ((localJsonSerializer1 instanceof ContextualSerializer))
return withResolved(paramBeanProperty, ((ContextualSerializer)localJsonSerializer1).createContextual(paramSerializerProvider, paramBeanProperty), this._forceTypeInformation);
return this;
}
示例12: findConvertingContentSerializer
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
public JsonSerializer<?> findConvertingContentSerializer(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty, JsonSerializer<?> paramJsonSerializer)
{
AnnotationIntrospector localAnnotationIntrospector = paramSerializerProvider.getAnnotationIntrospector();
if ((localAnnotationIntrospector != null) && (paramBeanProperty != null))
{
Object localObject = localAnnotationIntrospector.findSerializationContentConverter(paramBeanProperty.getMember());
if (localObject != null)
{
Converter localConverter = paramSerializerProvider.converterInstance(paramBeanProperty.getMember(), localObject);
JavaType localJavaType = localConverter.getOutputType(paramSerializerProvider.getTypeFactory());
if (paramJsonSerializer == null)
paramJsonSerializer = paramSerializerProvider.findValueSerializer(localJavaType, paramBeanProperty);
return new StdDelegatingSerializer(localConverter, localJavaType, paramJsonSerializer);
}
}
return paramJsonSerializer;
}
示例13: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
if (this._delegateSerializer != null)
{
if ((this._delegateSerializer instanceof ContextualSerializer))
{
JsonSerializer localJsonSerializer = ((ContextualSerializer)this._delegateSerializer).createContextual(paramSerializerProvider, paramBeanProperty);
if (localJsonSerializer == this._delegateSerializer)
return this;
return withDelegate(this._converter, this._delegateType, localJsonSerializer);
}
return this;
}
JavaType localJavaType1 = this._delegateType;
JavaType localJavaType2 = localJavaType1;
if (localJavaType1 == null)
localJavaType2 = this._converter.getOutputType(paramSerializerProvider.getTypeFactory());
return withDelegate(this._converter, localJavaType2, paramSerializerProvider.findValueSerializer(localJavaType2, paramBeanProperty));
}
示例14: _constructWriter
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
protected BeanPropertyWriter _constructWriter(SerializerProvider paramSerializerProvider, BeanPropertyDefinition paramBeanPropertyDefinition, TypeBindings paramTypeBindings, PropertyBuilder paramPropertyBuilder, boolean paramBoolean, AnnotatedMember paramAnnotatedMember)
{
String str = paramBeanPropertyDefinition.getName();
if (paramSerializerProvider.canOverrideAccessModifiers())
paramAnnotatedMember.fixAccess();
JavaType localJavaType = paramAnnotatedMember.getType(paramTypeBindings);
BeanProperty.Std localStd = new BeanProperty.Std(str, localJavaType, paramBeanPropertyDefinition.getWrapperName(), paramPropertyBuilder.getClassAnnotations(), paramAnnotatedMember, paramBeanPropertyDefinition.isRequired());
JsonSerializer localJsonSerializer1 = findSerializerFromAnnotation(paramSerializerProvider, paramAnnotatedMember);
JsonSerializer localJsonSerializer2 = localJsonSerializer1;
if ((localJsonSerializer1 instanceof ResolvableSerializer))
((ResolvableSerializer)localJsonSerializer2).resolve(paramSerializerProvider);
if ((localJsonSerializer2 instanceof ContextualSerializer))
localJsonSerializer2 = ((ContextualSerializer)localJsonSerializer2).createContextual(paramSerializerProvider, localStd);
boolean bool = ClassUtil.isCollectionMapOrArray(localJavaType.getRawClass());
TypeSerializer localTypeSerializer1 = null;
if (bool)
localTypeSerializer1 = findPropertyContentTypeSerializer(localJavaType, paramSerializerProvider.getConfig(), paramAnnotatedMember);
TypeSerializer localTypeSerializer2 = findPropertyTypeSerializer(localJavaType, paramSerializerProvider.getConfig(), paramAnnotatedMember);
return paramPropertyBuilder.buildWriter(paramBeanPropertyDefinition, localJavaType, localJsonSerializer2, localTypeSerializer2, localTypeSerializer1, paramAnnotatedMember, paramBoolean);
}
示例15: createContextual
import com.fasterxml.jackson.databind.BeanProperty; //導入依賴的package包/類
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
KeyDeserializer keyDeser = keyDeserializer;
JsonDeserializer<?> deser = valueDeserializer;
TypeDeserializer typeDeser = typeDeserializerForValue;
if ((keyDeser != null) && (deser != null) && (typeDeser == null)) {
return this;
}
if (keyDeser == null) {
keyDeser = ctxt.findKeyDeserializer(mapType.getKeyType(), property);
}
if (deser == null) {
deser = ctxt.findContextualValueDeserializer(mapType.getContentType(), property);
}
if (typeDeser != null) {
typeDeser = typeDeser.forProperty(property);
}
return withResolved(keyDeser, typeDeser, deser);
}