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


Java Annotated類代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.introspect.Annotated的典型用法代碼示例。如果您正苦於以下問題:Java Annotated類的具體用法?Java Annotated怎麽用?Java Annotated使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Annotated類屬於com.fasterxml.jackson.databind.introspect包,在下文中一共展示了Annotated類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getObjectMapper

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Bean(name = "objectMapper")
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();

    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new Jdk8Module());
    mapper.registerModule(new JodaModule());
    mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {
        // borrowed from: http://jackson-users.ning.com/forum/topics/how-to-not-include-type-info-during-serialization-with
        @Override
        protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ann, JavaType baseType) {

            // Don't serialize JsonTypeInfo Property includes
            if (ann.hasAnnotation(JsonTypeInfo.class)
                    && ann.getAnnotation(JsonTypeInfo.class).include() == JsonTypeInfo.As.PROPERTY
                    && SerializationConfig.class.isAssignableFrom(config.getClass())) {
                return null;

            }

            return super._findTypeResolver(config, ann, baseType);
        }
    });

    return mapper;
}
 
開發者ID:bpatters,項目名稱:eservice,代碼行數:27,代碼來源:CommonBeans.java

示例2: findSerializer

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findSerializer(Annotated annotatedMethod) {
	IdFormat annotation = annotatedMethod.getAnnotation(IdFormat.class);
	if (annotatedMethod.getRawType() == UUID.class) {
		if (annotation != null) {
			switch (annotation.value()) {
				case RAW:
					return UUIDSerializer.class;
				case URL62:
					return FriendlyIdSerializer.class;
			}
		}
		return FriendlyIdSerializer.class;
	} else {
		return null;
	}
}
 
開發者ID:Devskiller,項目名稱:friendly-id,代碼行數:18,代碼來源:FriendlyIdAnnotationIntrospector.java

示例3: findDeserializer

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findDeserializer(Annotated annotatedMethod) {
	IdFormat annotation = annotatedMethod.getAnnotation(IdFormat.class);
	if (rawDeserializationType(annotatedMethod) == UUID.class) {
		if (annotation != null) {
			switch (annotation.value()) {
				case RAW:
					return UUIDDeserializer.class;
				case URL62:
					return FriendlyIdDeserializer.class;
			}
		}
		return FriendlyIdDeserializer.class;
	} else {
		return null;
	}
}
 
開發者ID:Devskiller,項目名稱:friendly-id,代碼行數:18,代碼來源:FriendlyIdAnnotationIntrospector.java

示例4: findDeserializer

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findDeserializer(Annotated a) {
	// System.err.println("Annotated:" + a.getClass().getName() + " " + a);

	if (a instanceof AnnotatedClass) {
		Class<?> clazz = ((AnnotatedClass) a).getAnnotated();
		// System.err.println("clazz:" + clazz.getName() + " " + a.getName());

		if (clazz.isEnum()) {
			if (Onum.class.isAssignableFrom(clazz)) {
				// System.err.println("OnumJsonSerializerIntrospector findDeserializer:" + clazz.getName() + " a:" + a);
				return new OnumJsonDeserializer(clazz);
			}
		}
	}

	Object deserializer = super.findDeserializer(a);
	return deserializer;
}
 
開發者ID:tanhaichao,項目名稱:leopard,代碼行數:20,代碼來源:DisablingJsonSerializerIntrospector.java

示例5: getObjectMapper

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
ObjectMapper getObjectMapper() {
        ObjectMapper objectMapper = ObjectMapperBuilder.buildNewObjectMapper();
//        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        SimpleModule module = new SimpleModule();
        module.addSerializer(BigDecimal.class, new ToStringSerializer());
        module.addSerializer(Long.class, new ToStringSerializer());
        objectMapper.registerModule(module);

        //Disable JsonIdentityInfo
        JacksonAnnotationIntrospector ignoreJsonTypeInfoIntrospector = new JacksonAnnotationIntrospector() {
            @Override
            public ObjectIdInfo findObjectIdInfo(Annotated ann) {
                return null;
            }
        };
        objectMapper.setAnnotationIntrospector(ignoreJsonTypeInfoIntrospector);

        return objectMapper;
    }
 
開發者ID:factoryfx,項目名稱:factoryfx,代碼行數:20,代碼來源:HttpServer.java

示例6: findDeserializationConverter

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findDeserializationConverter(Annotated a) {
    JtToMap ann = a.getAnnotation(JtToMap.class);
    if (ann == null) {
        return null;
    }
    JavaType javaType = a.getType();
    if(a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if(am.getParameterCount() == 1) {
            javaType = am.getParameterType(0);
        } else {
            throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
        }
    }
    return new DeserializationConverterImpl(ann, new Ctx(a, javaType));
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:18,代碼來源:JtModule.java

示例7: findDeserializationConverter

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findDeserializationConverter(Annotated a) {
    Class<? extends PropertyInterceptor>[] interceptors = getInterceptors(a);
    if (interceptors == null) {
        return null;
    }
    JavaType javaType = a.getType();
    if(a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if(am.getParameterCount() == 1) {
            javaType = am.getParameterType(0);
        } else {
            throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
        }
    }
    return new KvInterceptorsDeserializationConverter(interceptors, new KvPropertyContextImpl(a, javaType));
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:18,代碼來源:KvSupportModule.java

示例8: setup

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Before
public void setup() {
	typeResolver = mock(TypeResolver.class);
	configuration = Configuration.build();
	
	instantiator = mock(HandlerInstantiator.class);
	
	doReturn(new ResourceDeserializer(Object.class, typeResolver, configuration))
		.when(instantiator).deserializerInstance(any(DeserializationConfig.class),
				any(Annotated.class), eq(ResourceDeserializer.class));
			
	mapper = new ObjectMapper();
	mapper.setHandlerInstantiator(instantiator);
	mapper.registerModule(new Jackson2HalModule());
	mapper.registerModule(new TestModule());
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
開發者ID:BlackPepperSoftware,項目名稱:bowman,代碼行數:18,代碼來源:ResourceDeserializerTest.java

示例9: findNameForSerialization

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public PropertyName findNameForSerialization(Annotated a) {
	if (!(a instanceof AnnotatedField) && !(a instanceof AnnotatedMethod)) {
		return super.findNameForSerialization(a);
	}

	IndexableProperty property = a.getAnnotation(IndexableProperty.class);
	if (property != null && !property.name().isEmpty()) {
		return new PropertyName(property.name());
	}

	IndexableComponent component = a.getAnnotation(IndexableComponent.class);
	if (component != null && !component.name().isEmpty()) {
		return new PropertyName(component.name());
	}

	IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
	if (properties != null && !properties.name().isEmpty()) {
		return new PropertyName(properties.name());
	}

	return PropertyName.USE_DEFAULT;
}
 
開發者ID:aureliano,項目名稱:evt-bridge,代碼行數:24,代碼來源:ElasticSearchAnnotationIntrospector.java

示例10: findSerializationInclusion

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) {
	IndexableProperty property = a.getAnnotation(IndexableProperty.class);
	if (property != null && property.jsonInclude() != com.github.aureliano.evtbridge.output.elasticsearch.enumeration.JsonInclude.DEFAULT) {
		return JsonInclude.Include.valueOf(property.jsonInclude().toString());
	}

	IndexableComponent component = a.getAnnotation(IndexableComponent.class);
	if (component != null && component.jsonInclude() != com.github.aureliano.evtbridge.output.elasticsearch.enumeration.JsonInclude.DEFAULT) {
		return JsonInclude.Include.valueOf(component.jsonInclude().toString());
	}

	IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
	if (properties != null && properties.jsonInclude() != com.github.aureliano.evtbridge.output.elasticsearch.enumeration.JsonInclude.DEFAULT) {
		return JsonInclude.Include.valueOf(properties.jsonInclude().toString());
	}
	return defValue;
}
 
開發者ID:aureliano,項目名稱:evt-bridge,代碼行數:19,代碼來源:ElasticSearchAnnotationIntrospector.java

示例11: findNameForDeserialization

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public PropertyName findNameForDeserialization(Annotated a) {
	if (!(a instanceof AnnotatedField) && !(a instanceof AnnotatedMethod)) {
		return super.findNameForDeserialization(a);
	}

	IndexableProperty property = a.getAnnotation(IndexableProperty.class);
	if (property != null && !property.name().isEmpty()) {
		return new PropertyName(property.name());
	}

	IndexableComponent component = a.getAnnotation(IndexableComponent.class);
	if (component != null && !component.name().isEmpty()) {
		return new PropertyName(component.name());
	}

	IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
	if (properties != null && !properties.name().isEmpty()) {
		return new PropertyName(properties.name());
	}

	return PropertyName.USE_DEFAULT;
}
 
開發者ID:aureliano,項目名稱:evt-bridge,代碼行數:24,代碼來源:ElasticSearchAnnotationIntrospector.java

示例12: createContextual

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的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

示例13: findSerializer

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findSerializer( Annotated annotated ) {

    if( ! annotated.hasAnnotation(Column.class) || ! isStringType(annotated) ) {
        return super.findSerializer( annotated );
    }

    Class classType = annotated.getRawType();

    if( Types.isNotString(classType) ) {
        if( Types.isBoolean(classType) ) {
            return ColumnBooleanSerializer.class;
        } else if( ! Types.isPrimitive(classType) ) {
            return ColumnBeanSerializer.class;
        }
    }

    return super.findSerializer( annotated );

}
 
開發者ID:NyBatis,項目名稱:NyBatisCore,代碼行數:21,代碼來源:ColumnAnnotationInspector.java

示例14: findDeserializer

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
@Override
public Object findDeserializer( Annotated annotated ) {

    if( ! annotated.hasAnnotation(Column.class) || ! isStringType(annotated) ) {
        return super.findDeserializer( annotated );
    }

    Class classType;
    try {
        classType = ( (AnnotatedMethod) annotated ).getRawParameterType( 0 );
    } catch( Exception e ) {
        classType = annotated.getRawType();
    }

    if( Types.isNotString(classType) ) {
        if( Types.isBoolean(classType) ) {
            return ColumnBooleanDeserializer.class;
        } else if( ! Types.isPrimitive(classType) ) {
            return ColumnBeanDeserializer.class;
        }
    }

    return super.findDeserializer( annotated );

}
 
開發者ID:NyBatis,項目名稱:NyBatisCore,代碼行數:26,代碼來源:ColumnAnnotationInspector.java

示例15: getPropertyName

import com.fasterxml.jackson.databind.introspect.Annotated; //導入依賴的package包/類
private PropertyName getPropertyName( Annotated annotated ) {

        Column column = annotated.getAnnotation( Column.class );
        if ( column != null && StringUtil.isNotEmpty(annotated.getName()) ) {
            String name = column.name();
            name = StringUtil.toUncamel( name );
            name = StringUtil.toCamel( name );
            return new PropertyName( name );
        }

        JsonProperty jsonProperty = annotated.getAnnotation( JsonProperty.class );
        if( jsonProperty != null ) {
            if( StringUtil.isNotEmpty(jsonProperty.value()) ) {
                return new PropertyName( jsonProperty.value() );
            } else {
                return PropertyName.USE_DEFAULT;
            }
        }

        return null;

    }
 
開發者ID:NyBatis,項目名稱:NyBatisCore,代碼行數:23,代碼來源:ColumnAnnotationInspector.java


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