當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanProperty類代碼示例

本文整理匯總了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());
		}
	});
}
 
開發者ID:JsonSchema-JavaUI,項目名稱:sf-java-ui,代碼行數:18,代碼來源:PasswordSchemaDecorator.java

示例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());
		}
	}
}
 
開發者ID:JsonSchema-JavaUI,項目名稱:sf-java-ui,代碼行數:19,代碼來源:TextFieldSchemaDecorator.java

示例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);
}
 
開發者ID:tanhaichao,項目名稱:leopard,代碼行數:22,代碼來源:ContextualJsonSerializer.java

示例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;
}
 
開發者ID:FasterXML,項目名稱:jackson-modules-java8,代碼行數:27,代碼來源:JSR310DateTimeDeserializerBase.java

示例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);
}
 
開發者ID:blomqvie,項目名稱:android-rxjava-training,代碼行數:22,代碼來源:TotallylazyCollectionDeserializer.java

示例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;
}
 
開發者ID:bootique,項目名稱:bootique,代碼行數:23,代碼來源:JSR310DateTimeDeserializerBase.java

示例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;
				}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:23,代碼來源:PersistentCollectionSerializer.java

示例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);
}
 
開發者ID:soabase,項目名稱:soabase,代碼行數:26,代碼來源:GuiceBundle.java

示例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);
    }
}
 
開發者ID:ScaCap,項目名稱:spring-auto-restdocs,代碼行數:19,代碼來源:FieldDocumentationObjectVisitor.java

示例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);
    }
}
 
開發者ID:CIDARLAB,項目名稱:clotho3crud,代碼行數:22,代碼來源:InstantiatedReferencesQueryingCache.java

示例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;
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:17,代碼來源:JsonValueSerializer.java

示例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;
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:18,代碼來源:StdSerializer.java

示例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));
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:20,代碼來源:StdDelegatingSerializer.java

示例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);
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:21,代碼來源:BeanSerializerFactory.java

示例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);
}
 
開發者ID:v1ctor,項目名稱:jackson-datatype-bolts,代碼行數:20,代碼來源:MapDeserializer.java


注:本文中的com.fasterxml.jackson.databind.BeanProperty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。