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


Java Jdk8Module类代码示例

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


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

示例1: createObjectMapper

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .registerModule(new Jdk8Module())
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:20,代码来源:YamlHelpers.java

示例2: getObjectMapper

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的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

示例3: getApiService

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
/**
 * Gets api service.
 *
 * @param enableHTTPLogging boolean to enable logging
 * @return the bot api service
 */
public static TelegramBotApiService getApiService(Boolean enableHTTPLogging) {
    if (ApiService == null) {
        Logger.info("No instance of service yet. Building...");
        ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module());
        Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
                .baseUrl("https://api.telegram.org/bot" + Token + "/")
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(JacksonConverterFactory.create(objectMapper));
        if (enableHTTPLogging) {
            Logger.info("Adding request logging...");
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
            httpClient.addInterceptor(httpLoggingInterceptor);
            retrofitBuilder.client(httpClient.build());
        }
        Retrofit retrofit = retrofitBuilder.build();
        ApiService = retrofit.create(TelegramBotApiService.class);
    }
    Logger.debug("Returning ApiService instance.");
    return ApiService;
}
 
开发者ID:iSDP,项目名称:Telebot,代码行数:29,代码来源:Telebot.java

示例4: configure

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Override
protected void configure() {
  requireBinding(ServiceMetadata.class);
  requireBinding(UriInfo.class);

  bind(AvailabilityResource.class).to(AvailabilityResourceImpl.class);
  bind(HealthResource.class).to(HealthResourceImpl.class);
  bind(DependenciesResource.class).to(DependenciesResourceImpl.class);
  bind(DiagnosticResource.class).to(DiagnosticResourceImpl.class);
  bind(VersionResource.class).to(VersionResourceImpl.class);
  bind(HealthChecker.class);

  //This is to provide a default binding for HealthDependency,
  // so that services with no HealthDependency bindings can start
  Multibinder<HealthDependency> healthDependencyModuleBinder = Multibinder.newSetBinder(binder(),
      HealthDependency.class);

  Multibinder<Module> jacksonModuleBinder = Multibinder.newSetBinder(binder(), Module.class);
  jacksonModuleBinder.addBinding().to(Jdk8Module.class);
  jacksonModuleBinder.addBinding().to(JavaTimeModule.class);

  install(MultibindingsScanner.asModule());
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:24,代码来源:HealthModule.java

示例5: createObjectMapper

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
private static ObjectMapper createObjectMapper() {

        ObjectMapper mapper = new ObjectMapper();

        mapper.registerModule(new Jdk8Module());
        mapper.registerModule(new JavaTimeModule());
        mapper.registerModule(new ParameterNamesModule());

        mapper.enable(SerializationFeature.INDENT_OUTPUT);
        mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
        mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);

        return mapper;
    }
 
开发者ID:cassiomolin,项目名称:jersey-jwt-springsecurity,代码行数:18,代码来源:ObjectMapperProvider.java

示例6: testConvertFromJson

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Ignore("test-integration.json is outdated")
@Test
public void testConvertFromJson() throws Exception {
    JsonNode json = new ObjectMapper().readTree(this.getClass().getResourceAsStream("test-integration.json"));
    Integration integration = new ObjectMapper().registerModule(new Jdk8Module()).readValue(json.get("data").toString(), Integration.class);

    ProjectGeneratorProperties generatorProperties = new ProjectGeneratorProperties(MAVEN_PROPERTIES);
    generatorProperties.getTemplates().setOverridePath(this.basePath);
    generatorProperties.getTemplates().getAdditionalResources().addAll(this.additionalResources);

    Path runtimePath = generate(integration, generatorProperties);

    assertFileContents(generatorProperties, runtimePath.resolve("src/main/java/io/syndesis/example/Application.java"), "test-Application.java");
    assertFileContents(generatorProperties, runtimePath.resolve("src/main/resources/application.properties"), "test-pull-push-application.properties");
    assertFileContents(generatorProperties, runtimePath.resolve("src/main/resources/syndesis.yml"), "test-pull-push-syndesis.yml");
    assertFileContents(generatorProperties, runtimePath.resolve("pom.xml"), "test-pull-push-pom.xml");
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:DefaultProjectGeneratorTest.java

示例7: deserializationEntityTypeTest

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Test
public void deserializationEntityTypeTest() throws IOException {

    ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module());
    Registration registration = objectMapper.readValue(jsonString, Registration.class);
    assertEquals("abcdefg", registration.getId());
    assertEquals(new URL("http://weather.example.com/ngsi"), registration.getCallback());
    assertEquals("PT1M", registration.getDuration());
    assertEquals(1, registration.getSubject().getEntities().size());
    assertEquals("Bcn_Welt", registration.getSubject().getEntities().get(0).getId().get());
    assertEquals("Room", registration.getSubject().getEntities().get(0).getType().get());
    assertEquals(1, registration.getSubject().getAttributes().size());
    assertEquals("temperature", registration.getSubject().getAttributes().get(0));
    assertEquals(2, registration.getMetadata().size());
    assertTrue(registration.getMetadata().containsKey("providingService"));
    assertTrue(registration.getMetadata().containsKey("providingAuthority"));
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:18,代码来源:RegistrationTest.java

示例8: deserializationEntityTest

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Test
public void deserializationEntityTest() throws IOException {
    String jsonString = "{\n" +
            "  \"id\" : \"Bcn-Welt\",\n" +
            "  \"type\" : \"Room\",\n" +
            "  \"temperature\" : {\n" +
            "    \"value\" : 21.7\n" +
            "  },\n" +
            "  \"humidity\" : {\n" +
            "    \"value\" : 60\n" +
            "  }\n" +
            "}";
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module());
    Entity entity = objectMapper.readValue(jsonString, Entity.class);
    Attribute temp = entity.getAttributes().get("temperature");
    assertEquals(0, temp.getMetadata().size());
}
 
开发者ID:Orange-OpenSource,项目名称:fiware-ngsi2-api,代码行数:18,代码来源:EntityTest.java

示例9: before

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Before
public void before() throws Throwable {
    mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());

    Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder()
            .setUser("")
            .setName(RetzScheduler.FRAMEWORK_NAME)
            .build();

    InputStream in = Launcher.class.getResourceAsStream("/retz.properties");
    Launcher.Configuration conf = new Launcher.Configuration(new ServerConfiguration(in));

    Database.getInstance().init(conf.getServerConfig());
    scheduler = new RetzScheduler(conf, frameworkInfo);
    driver = new MesosSchedulerDummyDriver(scheduler, frameworkInfo, conf.getMesosMaster());
}
 
开发者ID:retz,项目名称:retz,代码行数:18,代码来源:RetzSchedulerTest.java

示例10: connect

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
static Retz connect(
        URI uri,
        Authenticator authenticator,
        SSLSocketFactory socketFactory,
        HostnameVerifier hostnameVerifier) {
    String url = Objects.requireNonNull(uri, "uri cannot be null").toString();
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());
    return Feign.builder()
            .client(new Client.Default(socketFactory, hostnameVerifier))
            .logger(new Slf4jLogger())
            .encoder(new JacksonEncoder(mapper))
            .decoder(new JacksonDecoder(mapper))
            .errorDecoder(new ErrorResponseDecoder(mapper))
            .requestInterceptor(new AuthHeaderInterceptor(authenticator))
            .target(Retz.class, url);
}
 
开发者ID:retz,项目名称:retz,代码行数:18,代码来源:Retz.java

示例11: handle

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Override
public int handle(ClientCLIConfig fileConfig, boolean verbose) throws Throwable {
    LOG.debug("Configuration: {}", fileConfig.toString());

    try (Client webClient = Client.newBuilder(fileConfig.getUri())
            .setAuthenticator(fileConfig.getAuthenticator())
            .checkCert(!fileConfig.insecure())
            .setVerboseLog(verbose)
            .build()) {

        Response res = webClient.getApp(appName);
        if (res instanceof ErrorResponse) {
            LOG.error(res.status());
        } else if (res instanceof GetAppResponse) {
            GetAppResponse getAppResponse = (GetAppResponse) res;
            Application app = getAppResponse.application();

            ObjectMapper mapper = new ObjectMapper();
            mapper.registerModule(new Jdk8Module());
            mapper.writeValue(System.out, app);
            System.out.println();
            return 0;
        }
    }
    return -1;
}
 
开发者ID:retz,项目名称:retz,代码行数:27,代码来源:CommandGetApp.java

示例12: longTest

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Test
public void longTest() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());
    { // Test GH#81 https://github.com/retz/retz/issues/81
        String d = "{\"gid\":\"1000\",\"mode\":\"-rw-r--r--\",\"mtime\":1479109579.0,\"nlink\":1,\"path\":\"\\/var\\/lib\\/mesos\\/...\\/results\\/99.bin\",\"size\":5122002944,\"uid\":\"1000\"}";
        DirEntry entry = mapper.readValue(d, DirEntry.class);
        assertEquals(5122002944L, entry.size());
    }

    {
        String f = "{\"data\": \"deadbeef\", \"offset\":999999999999}";
        FileContent content = mapper.readValue(f, FileContent.class);
        assertEquals(999999999999L, content.offset());
    }
}
 
开发者ID:retz,项目名称:retz,代码行数:17,代码来源:DataTest.java

示例13: test1

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Test
public void test1() {
	InstanceData_old data = InstanceDataGenerator_old.build();
	System.out.println(data.toString());

	try {
		ObjectMapper mapper = new ObjectMapper().registerModule(new Jdk8Module());
		SimpleModule module = new SimpleModule();
		module.addKeyDeserializer(TypeVMJobClassKey.class, TypeVMJobClassKey.getDeserializer() );
		mapper.registerModule(module);

		String serialized = mapper.writeValueAsString(data);
		System.out.println(serialized);

		InstanceData_old data2 = mapper.readValue(serialized, InstanceData_old.class);
		System.out.println(data2.toString());
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	assertTrue(data.getGamma() ==240);
}
 
开发者ID:deib-polimi,项目名称:diceH2020-space4clouds_shared,代码行数:23,代码来源:Test2.java

示例14: beforeAll

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
@Before
public void beforeAll() throws Exception {
    server = new TestingServer();
    server.start();
    Capabilities mockCapabilities = Mockito.mock(Capabilities.class);
    when(mockCapabilities.supportsNamedVips()).thenReturn(true);
    taskFactory = new CassandraDaemonTask.Factory(mockCapabilities);
    configurationFactory = new ConfigurationFactory<>(
                    MutableSchedulerConfiguration.class,
                    BaseValidator.newValidator(),
                    Jackson.newObjectMapper()
                            .registerModule(new GuavaModule())
                            .registerModule(new Jdk8Module()),
                    "dw");
    connectString = server.getConnectString();
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:17,代码来源:ConfigurationManagerTest.java

示例15: setupMapper

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; //导入依赖的package包/类
private static ObjectMapper setupMapper() {
        ObjectMapper objectMapper = new ObjectMapper();

        objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
        objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
        objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
//        objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);

        SimpleModule m = new SimpleModule();
        objectMapper.registerModule(m);

        objectMapper.registerModule(new JavaTimeModule());
        objectMapper.registerModule(new Jdk8Module());
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
//            objectMapper.disable(DeserializationFeature.);
        objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//            objectMapper.enableDefaultTyping();

        objectMapper.addMixIn(Color.class, ColorMixInAnnotations.class);
        return objectMapper;
    }
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:24,代码来源:ObjectMapperBuilder.java


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