Example usage for com.fasterxml.jackson.databind ObjectMapper findMixInClassFor

List of usage examples for com.fasterxml.jackson.databind ObjectMapper findMixInClassFor

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectMapper findMixInClassFor.

Prototype

public final Class<?> findMixInClassFor(Class<?> cls) 

Source Link

Usage

From source file:springfox.documentation.swagger1.configuration.SwaggerJacksonModule.java

private static boolean isModuleSetup(ObjectMapper objectMapper) {
    return objectMapper.findMixInClassFor(ApiListing.class) == null;
}

From source file:org.springframework.hateoas.hal.Jackson2HalModule.java

/**
 * Returns whether the module was already registered in the given
 * {@link ObjectMapper}.//from w  ww  . ja  v  a 2s .c om
 *
 * @param mapper
 *            must not be {@literal null}.
 * @return
 */
public static boolean isAlreadyRegisteredIn(ObjectMapper mapper) {

    Assert.notNull(mapper, "ObjectMapper must not be null!");
    return LinkMixin.class.equals(mapper.findMixInClassFor(Link.class));
}

From source file:springfox.documentation.swagger2.configuration.Swagger2JacksonModule.java

public void maybeRegisterModule(ObjectMapper objectMapper) {
    if (objectMapper.findMixInClassFor(Swagger.class) == null) {
        objectMapper.registerModule(new Swagger2JacksonModule());
        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    }//from   w w  w  . j av  a2 s  . c om
}

From source file:org.lambdamatic.internal.elasticsearch.codec.ObjectMapperFactoryTest.java

@Test
public void shouldInitializeObjectMapperWithMixins() {

    // when// w w  w.j a v  a2 s.c  o m
    final ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
    // then
    assertThat(objectMapper.findMixInClassFor(Location.class)).isEqualTo(LocationMixin.class);
}

From source file:org.springframework.cloud.dataflow.rest.client.DataflowTemplateTests.java

private void assertCorrectMixins(RestTemplate restTemplate) {
    boolean containsMappingJackson2HttpMessageConverter = false;

    for (HttpMessageConverter<?> converter : restTemplate.getMessageConverters()) {
        if (converter instanceof MappingJackson2HttpMessageConverter) {
            containsMappingJackson2HttpMessageConverter = true;

            final MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
            final ObjectMapper objectMapper = jacksonConverter.getObjectMapper();

            assertNotNull(objectMapper.findMixInClassFor(JobExecution.class));
            assertNotNull(objectMapper.findMixInClassFor(JobParameters.class));
            assertNotNull(objectMapper.findMixInClassFor(JobParameter.class));
            assertNotNull(objectMapper.findMixInClassFor(JobInstance.class));
            assertNotNull(objectMapper.findMixInClassFor(ExitStatus.class));
            assertNotNull(objectMapper.findMixInClassFor(StepExecution.class));
            assertNotNull(objectMapper.findMixInClassFor(ExecutionContext.class));
            assertNotNull(objectMapper.findMixInClassFor(StepExecutionHistory.class));
        }//from   w  ww  .  j ava2 s. co m
    }

    if (!containsMappingJackson2HttpMessageConverter) {
        fail("Expected that the restTemplate's list of Message Converters contained a "
                + "MappingJackson2HttpMessageConverter");
    }
}