当前位置: 首页>>代码示例>>Java>>正文


Java HandlerInstantiator类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.cfg.HandlerInstantiator的典型用法代码示例。如果您正苦于以下问题:Java HandlerInstantiator类的具体用法?Java HandlerInstantiator怎么用?Java HandlerInstantiator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HandlerInstantiator类属于com.fasterxml.jackson.databind.cfg包,在下文中一共展示了HandlerInstantiator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInstantiatesObjectMapperWithInlineAssociationDeserializerAwareHandlerInstantiator

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Test
public void createInstantiatesObjectMapperWithInlineAssociationDeserializerAwareHandlerInstantiator() {
	ObjectMapper mapper = new ObjectMapper();
	RestTemplate restTemplate = new RestTemplate();
	
	when(mapperFactory.create(any(HandlerInstantiator.class))).thenReturn(mapper);
	when(restTemplateFactory.create(any(ClientHttpRequestFactory.class), any(ObjectMapper.class)))
		.thenReturn(restTemplate);
	
	factory.create();

	ArgumentCaptor<HandlerInstantiator> handlerInstantiator = ArgumentCaptor.forClass(HandlerInstantiator.class);
	verify(mapperFactory).create(handlerInstantiator.capture());

	assertThat(handlerInstantiator.getValue().deserializerInstance(null, null, InlineAssociationDeserializer.class),
			is(anInlineAssociationDeserializerMatching(aRestOperationsMatching(restTemplate, mapper),
					proxyFactory)));
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:19,代码来源:RestOperationsFactoryTest.java

示例2: createInvokesConfigurerOnObjectMapperIfPresent

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Test
public void createInvokesConfigurerOnObjectMapperIfPresent() {
	ObjectMapperConfigurer objectMapperConfigurer = mock(ObjectMapperConfigurer.class);
	Configuration configuration = Configuration.builder()
		.setObjectMapperConfigurer(objectMapperConfigurer)
		.build();
	
	ObjectMapper objectMapper = new ObjectMapper();
	when(mapperFactory.create(any(HandlerInstantiator.class)))
		.thenReturn(objectMapper);
	
	new RestOperationsFactory(configuration, proxyFactory, mapperFactory, restTemplateFactory)
		.create();
	
	verify(objectMapperConfigurer).configure(objectMapper);
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:17,代码来源:RestOperationsFactoryTest.java

示例3: setup

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的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

示例4: _findNamingStrategy

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
private PropertyNamingStrategy _findNamingStrategy()
{
  Object localObject1;
  if (this._annotationIntrospector == null)
    localObject1 = null;
  else
    localObject1 = this._annotationIntrospector.findNamingStrategy(this._classDef);
  Object localObject2 = localObject1;
  if (localObject1 == null)
    return this._config.getPropertyNamingStrategy();
  if ((localObject2 instanceof PropertyNamingStrategy))
    return (PropertyNamingStrategy)localObject2;
  if (!(localObject2 instanceof Class))
    throw new IllegalStateException("AnnotationIntrospector returned PropertyNamingStrategy definition of type " + localObject2.getClass().getName() + "; expected type PropertyNamingStrategy or Class<PropertyNamingStrategy> instead");
  Class localClass = (Class)localObject2;
  if (!PropertyNamingStrategy.class.isAssignableFrom(localClass))
    throw new IllegalStateException("AnnotationIntrospector returned Class " + localClass.getName() + "; expected Class<PropertyNamingStrategy>");
  HandlerInstantiator localHandlerInstantiator = this._config.getHandlerInstantiator();
  if (localHandlerInstantiator != null)
  {
    PropertyNamingStrategy localPropertyNamingStrategy = localHandlerInstantiator.namingStrategyInstance(this._config, this._classDef, localClass);
    if (localPropertyNamingStrategy != null)
      return localPropertyNamingStrategy;
  }
  return (PropertyNamingStrategy)ClassUtil.createInstance(localClass, this._config.canOverrideAccessModifiers());
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:POJOPropertiesCollector.java

示例5: _valueInstantiatorInstance

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig paramDeserializationConfig, Annotated paramAnnotated, Object paramObject)
{
  if (paramObject == null)
    return null;
  if ((paramObject instanceof ValueInstantiator))
    return (ValueInstantiator)paramObject;
  if (!(paramObject instanceof Class))
    throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " + paramObject.getClass().getName() + "; expected type KeyDeserializer or Class<KeyDeserializer> instead");
  Class localClass = (Class)paramObject;
  if (localClass == NoClass.class)
    return null;
  if (!ValueInstantiator.class.isAssignableFrom(localClass))
    throw new IllegalStateException("AnnotationIntrospector returned Class " + localClass.getName() + "; expected Class<ValueInstantiator>");
  HandlerInstantiator localHandlerInstantiator = paramDeserializationConfig.getHandlerInstantiator();
  if (localHandlerInstantiator != null)
  {
    ValueInstantiator localValueInstantiator = localHandlerInstantiator.valueInstantiatorInstance(paramDeserializationConfig, paramAnnotated, localClass);
    if (localValueInstantiator != null)
      return localValueInstantiator;
  }
  return (ValueInstantiator)ClassUtil.createInstance(localClass, paramDeserializationConfig.canOverrideAccessModifiers());
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:23,代码来源:BasicDeserializerFactory.java

示例6: objectIdGeneratorInstance

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated,
        ObjectIdInfo objectIdInfo)
    throws JsonMappingException
{
    Class<?> implClass = objectIdInfo.getGeneratorType();
    HandlerInstantiator hi = _config.getHandlerInstantiator();
    ObjectIdGenerator<?> gen;

    if (hi != null) {
        gen =  hi.objectIdGeneratorInstance(_config, annotated, implClass);
    } else {
        gen = (ObjectIdGenerator<?>) ClassUtil.createInstance(implClass,
                _config.canOverrideAccessModifiers());
    }
    return gen.forScope(objectIdInfo.getScope());
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:18,代码来源:DefaultSerializerProvider.java

示例7: objectIdGeneratorInstance

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated,
        ObjectIdInfo objectIdInfo)
    throws JsonMappingException
{
    Class<?> implClass = objectIdInfo.getGeneratorType();
    HandlerInstantiator hi = _config.getHandlerInstantiator();
    ObjectIdGenerator<?> gen;

    if (hi != null) {
        gen = hi.objectIdGeneratorInstance(_config, annotated, implClass);
    } else {
        gen = (ObjectIdGenerator<?>) ClassUtil.createInstance(implClass,
                _config.canOverrideAccessModifiers());
    }
    return gen.forScope(objectIdInfo.getScope());
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:18,代码来源:DefaultDeserializationContext.java

示例8: jacksonBuilder

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
/**
 * Needed to override JSON De-/Serializer in Jackson.
 *
 * @param handlerInstantiator
 * @return
 */
@Bean
public Jackson2ObjectMapperBuilder jacksonBuilder(HandlerInstantiator handlerInstantiator) {
    Jackson2ObjectMapperBuilder b = new Jackson2ObjectMapperBuilder();
    b.indentOutput(true).mixIn(Workbasket.class, WorkbasketMixIn.class);
    b.handlerInstantiator(handlerInstantiator);
    return b;
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:14,代码来源:RestApplication.java

示例9: create

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Override
public ObjectMapper create(HandlerInstantiator instantiator) {
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.registerModule(new Jackson2HalModule());
	mapper.registerModule(new JacksonClientModule());
	mapper.setHandlerInstantiator(instantiator);
	return mapper;
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:10,代码来源:DefaultObjectMapperFactory.java

示例10: createReturnsRestOperations

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Test
public void createReturnsRestOperations() {
	ObjectMapper mapper = new ObjectMapper();
	RestTemplate restTemplate = new RestTemplate();
	
	when(mapperFactory.create(any(HandlerInstantiator.class))).thenReturn(mapper);
	when(restTemplateFactory.create(clientHttpRequestFactory, mapper)).thenReturn(restTemplate);
	
	RestOperations restOperations = factory.create();
	
	assertThat(restOperations, is(aRestOperationsMatching(restTemplate, mapper)));
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:13,代码来源:RestOperationsFactoryTest.java

示例11: setup

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Before
public void setup() {
	RestOperations restOperations = mock(RestOperations.class);
	ClientProxyFactory proxyFactory = new JavassistClientProxyFactory();
	
	instantiator = mock(HandlerInstantiator.class);
	
	doReturn(new InlineAssociationDeserializer<>(Object.class, restOperations, proxyFactory))
		.when(instantiator).deserializerInstance(any(DeserializationConfig.class),
				any(Annotated.class), eq(InlineAssociationDeserializer.class));
			
	mapper = new ObjectMapper();
	mapper.setHandlerInstantiator(instantiator);
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:16,代码来源:InlineAssociationDeserializerTest.java

示例12: setup

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Before
public void setup() {
	HandlerInstantiator instantiator = mock(HandlerInstantiator.class);
	
	doReturn(declaredTypeResourceDeserializer()).when(instantiator).deserializerInstance(
		any(DeserializationConfig.class), any(Annotated.class), eq(ResourceDeserializer.class));
	
	restTemplate = mock(RestTemplate.class);
	objectMapper = new DefaultObjectMapperFactory().create(instantiator);

	restOperations = new RestOperations(restTemplate, objectMapper);
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:13,代码来源:RestOperationsTest.java

示例13: serializerInstance

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
public JsonSerializer<Object> serializerInstance(Annotated paramAnnotated, Object paramObject)
{
  if (paramObject == null)
    return null;
  Object localObject;
  if ((paramObject instanceof JsonSerializer))
  {
    localObject = (JsonSerializer)paramObject;
  }
  else
  {
    if (!(paramObject instanceof Class))
      throw new IllegalStateException("AnnotationIntrospector returned serializer definition of type " + paramObject.getClass().getName() + "; expected type JsonSerializer or Class<JsonSerializer> instead");
    Class localClass = (Class)paramObject;
    if ((localClass == JsonSerializer.None.class) || (localClass == NoClass.class))
      return null;
    if (!JsonSerializer.class.isAssignableFrom(localClass))
      throw new IllegalStateException("AnnotationIntrospector returned Class " + localClass.getName() + "; expected Class<JsonSerializer>");
    HandlerInstantiator localHandlerInstantiator = this._config.getHandlerInstantiator();
    JsonSerializer localJsonSerializer;
    if (localHandlerInstantiator == null)
      localJsonSerializer = null;
    else
      localJsonSerializer = localHandlerInstantiator.serializerInstance(this._config, paramAnnotated, localClass);
    localObject = localJsonSerializer;
    if (localJsonSerializer == null)
      localObject = (JsonSerializer)ClassUtil.createInstance(localClass, this._config.canOverrideAccessModifiers());
  }
  return _handleResolvable((JsonSerializer)localObject);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:31,代码来源:DefaultSerializerProvider.java

示例14: serializerInstance

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
@Override
public JsonSerializer<Object> serializerInstance(Annotated annotated,
        Object serDef)
    throws JsonMappingException

{
    if (serDef == null) {
        return null;
    }
    JsonSerializer<?> ser;
    
    if (serDef instanceof JsonSerializer) {
        ser = (JsonSerializer<?>) serDef;
    } else {
        /* Alas, there's no way to force return type of "either class
         * X or Y" -- need to throw an exception after the fact
         */
        if (!(serDef instanceof Class)) {
            throw new IllegalStateException("AnnotationIntrospector returned serializer definition of type "
                    +serDef.getClass().getName()+"; expected type JsonSerializer or Class<JsonSerializer> instead");
        }
        Class<?> serClass = (Class<?>)serDef;
        // there are some known "no class" markers to consider too:
        if (serClass == JsonSerializer.None.class || serClass == NoClass.class) {
            return null;
        }
        if (!JsonSerializer.class.isAssignableFrom(serClass)) {
            throw new IllegalStateException("AnnotationIntrospector returned Class "
                    +serClass.getName()+"; expected Class<JsonSerializer>");
        }
        HandlerInstantiator hi = _config.getHandlerInstantiator();
        if (hi != null) {
            ser = hi.serializerInstance(_config, annotated, serClass);
        } else {
            ser = (JsonSerializer<?>) ClassUtil.createInstance(serClass,
                    _config.canOverrideAccessModifiers());
        }
    }
    return (JsonSerializer<Object>) _handleResolvable(ser);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:41,代码来源:DefaultSerializerProvider.java

示例15: _findNamingStrategy

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; //导入依赖的package包/类
private PropertyNamingStrategy _findNamingStrategy()
{
    Object namingDef = (_annotationIntrospector == null)? null
            : _annotationIntrospector.findNamingStrategy(_classDef);
    if (namingDef == null) {
        return _config.getPropertyNamingStrategy();
    }
    if (namingDef instanceof PropertyNamingStrategy) {
        return (PropertyNamingStrategy) namingDef;
    }
    /* Alas, there's no way to force return type of "either class
     * X or Y" -- need to throw an exception after the fact
     */
    if (!(namingDef instanceof Class)) {
        throw new IllegalStateException("AnnotationIntrospector returned PropertyNamingStrategy definition of type "
                +namingDef.getClass().getName()+"; expected type PropertyNamingStrategy or Class<PropertyNamingStrategy> instead");
    }
    Class<?> namingClass = (Class<?>)namingDef;
    if (!PropertyNamingStrategy.class.isAssignableFrom(namingClass)) {
        throw new IllegalStateException("AnnotationIntrospector returned Class "
                +namingClass.getName()+"; expected Class<PropertyNamingStrategy>");
    }
    HandlerInstantiator hi = _config.getHandlerInstantiator();
    if (hi != null) {
        return hi.namingStrategyInstance(_config, _classDef, namingClass);
    }
    return (PropertyNamingStrategy) ClassUtil.createInstance(namingClass,
                _config.canOverrideAccessModifiers());
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:30,代码来源:POJOPropertiesCollector.java


注:本文中的com.fasterxml.jackson.databind.cfg.HandlerInstantiator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。