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


Java JavaTimeModule类代码示例

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


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

示例1: createSystemEvent

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
private String createSystemEvent(String tenant, String command) {
    SystemEvent event = new SystemEvent();
    event.setEventId(MDCUtil.getRid());
    event.setEventType(command);
    event.setTenantInfo(TenantContext.getCurrent());
    event.setMessageSource(appName);
    event.getData().put(Constants.EVENT_TENANT, tenant);
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JavaTimeModule());
    try {
        return mapper.writeValueAsString(event);
    } catch (JsonProcessingException e) {
        log.error("System Event mapping error", e);
        throw new BusinessException("Event mapping error", e.getMessage());
    }

}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:18,代码来源:KafkaService.java

示例2: start

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
    Json.mapper.registerModule(new JavaTimeModule());
	FileSystem vertxFileSystem = vertx.fileSystem();
    vertxFileSystem.readFile("swagger.json", readFile -> {
        if (readFile.succeeded()) {
            Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
            Router swaggerRouter = SwaggerRouter.swaggerRouter(Router.router(vertx), swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
        
            deployVerticles(startFuture);
            
            vertx.createHttpServer() 
                .requestHandler(swaggerRouter::accept) 
                .listen(8080);
            startFuture.complete();
        } else {
        	startFuture.fail(readFile.cause());
        }
    });        		        
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:21,代码来源:MainApiVerticle.java

示例3: start

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
    Json.mapper.registerModule(new JavaTimeModule());
	FileSystem vertxFileSystem = vertx.fileSystem();
    vertxFileSystem.readFile("swagger.json", readFile -> {
        if (readFile.succeeded()) {
            Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
            SwaggerManager.getInstance().setSwagger(swagger);
            Router swaggerRouter = SwaggerRouter.swaggerRouter(Router.router(vertx), swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
        
            deployVerticles(startFuture);

            vertx.createHttpServer() 
                .requestHandler(swaggerRouter::accept) 
                .listen(config().getInteger("http.port", 8080));
            startFuture.complete();
        } else {
        	startFuture.fail(readFile.cause());
        }
    });        		        
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:22,代码来源:MainApiVerticle.java

示例4: IiifObjectMapper

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
public IiifObjectMapper() {
  this.checkJacksonVersion();

  // Don't include null properties
  this.setSerializationInclusion(Include.NON_NULL);

  // Both are needed to add `@context` to the top-level object
  this.disable(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS);
  this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

  // Some array fields are unwrapped during serialization if they have only one value
  this.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

  // Register the problem handler
  this.addHandler(new ProblemHandler());

  // Disable writing dates as timestamps
  this.registerModule(new JavaTimeModule());
  this.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

  // Enable automatic detection of parameter names in @JsonCreators
  this.registerModule(new ParameterNamesModule());

  // Register the module
  this.registerModule(new IiifModule());
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:27,代码来源:IiifObjectMapper.java

示例5: convertObjectToJsonBytes

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
/**
 * Convert an object to JSON byte array.
 *
 * @param object
 *            the object to convert
 * @return the JSON byte array
 * @throws IOException
 */
public static byte[] convertObjectToJsonBytes(Object object)
        throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    JavaTimeModule module = new JavaTimeModule();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    mapper.registerModule(module);

    return mapper.writeValueAsBytes(object);
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:24,代码来源:TestUtil.java

示例6: configure

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

示例7: createObjectMapper

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

示例8: setUp

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
	super.setUp();

	client = new CrnkClient(getBaseUri().toString());
	client.getObjectMapper().registerModule(new JavaTimeModule());

	HttpAdapter httpAdapter = client.getHttpAdapter();
	httpAdapter.setReceiveTimeout(10000, TimeUnit.SECONDS);

	scheduleRepo = client.getRepositoryForInterface(ScheduleRepository.class);
	approvalRepo = client.getRepositoryForType(ScheduleApprovalProcessInstance.class);
	taskRepo = client.getRepositoryForType(ApproveTask.class);
	approvalRelRepo = client.getRepositoryForType(Schedule.class, ScheduleApprovalProcessInstance.class);
	formRepo = client.getRepositoryForType(ApproveForm.class);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:18,代码来源:ApprovalIntTest.java

示例9: getRegistryClient

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
private RegistryEndpoints getRegistryClient(ImageRef imageRef) {
	if (!proxyClients.containsKey(imageRef.getRegistryUrl())) {

		ObjectMapper mapper = new ObjectMapper();
		mapper.registerModule(new JavaTimeModule());

		Client client = ClientBuilder.newClient()
				.register(new JacksonJaxbJsonProvider(mapper, new Annotations[] {Annotations.JACKSON}))
				.register(JacksonFeature.class);
		String auth = config.getAuthFor(imageRef.getRegistryName());
		if (auth != null) {
			String[] credentials = new String(Base64.getDecoder().decode(auth), StandardCharsets.UTF_8).split(":");
			client.register(HttpAuthenticationFeature.basicBuilder().credentials(credentials[0], credentials[1]));
		}
		WebTarget webTarget = client.target(imageRef.getRegistryUrl());
		proxyClients.put(imageRef.getRegistryUrl(), WebResourceFactory.newResource(RegistryEndpoints.class, webTarget));
	}
	return proxyClients.get(imageRef.getRegistryUrl());
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:20,代码来源:DockerRegistry.java

示例10: initializeMapper

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
private static ObjectMapper initializeMapper() {
    return new ObjectMapper()
            .registerModule(new JavaTimeModule())

            .disable(MapperFeature.AUTO_DETECT_GETTERS)
            .disable(MapperFeature.AUTO_DETECT_CREATORS)
            .disable(MapperFeature.AUTO_DETECT_SETTERS)
            .disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
            .disable(MapperFeature.AUTO_DETECT_FIELDS)
            .disable(MapperFeature.DEFAULT_VIEW_INCLUSION)
            .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE)
            .enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
            .enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)

            // serialization
            .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
            .enable(SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID)
            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
            .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)

            // deserialization
            .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
            .enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:25,代码来源:JsonMapper.java

示例11: updateUserStatusGood

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Test
public void updateUserStatusGood() throws Exception {
    final UserEntity entity = TestUtil.getUserEntity();
    entity.setStatus(UserStatus.CLOSED);
    final List<String> roles = new ArrayList<>();
    roles.add(Role.ADMIN.getAuthority());

    mapper.registerModule(new JavaTimeModule());
    final byte[] content = mapper.writeValueAsBytes(new UserInfo(entity));

    when(claims.get(JwtToken.KEY)).thenReturn(roles);
    when(userService.updateUserStatus(anyString(), any(UserStatus.class))).thenReturn(entity);

    mockMvc.perform(put(UsersController.PATH + "/" + entity.getId() + "/status/" + UserStatus.CLOSED).contentType(MediaType.APPLICATION_JSON).content(content))
            .andExpect(status().isOk())

            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))

            .andExpect(jsonPath("$.id", Matchers.is(equalTo(entity.getId()))))
            .andExpect(jsonPath("$.status", Matchers.is(equalTo(UserStatus.CLOSED.toString()))));
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:22,代码来源:UsersControllerTest.java

示例12: testAddDatasetGoodAuthentication

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Test
public void testAddDatasetGoodAuthentication() throws Exception {
    final DataEntity dataEntity = TestUtil.getDataEntity();
    dataEntity.setCategoryId(getDataCategoryEntity().getId());

    mapper.registerModule(new JavaTimeModule());
    final byte[] content = mapper.writeValueAsBytes(new DataInfo(dataEntity));

    when(securityContext.getAuthentication()).thenReturn(authentication);
    SecurityContextHolder.setContext(securityContext);
    when(authentication.getPrincipal()).thenReturn(claims);
    when(dataService.createDataset(any(DataInfo.class))).thenReturn(dataEntity);

    mockMvc.perform(post(DataController.PATH)
            .contentType(MediaType.APPLICATION_JSON)
            .content(content))

            .andExpect(status().isCreated())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))

            .andExpect(jsonPath("name", is(equalTo(dataEntity.getName()))))
            .andExpect(jsonPath("description", is(equalTo(dataEntity.getDescription()))))
            .andExpect(jsonPath("contributorId", is(equalTo(dataEntity.getContributorId()))))
            .andExpect(jsonPath("accessibility", is(equalTo(dataEntity.getAccessibility().toString()))))
            .andExpect(jsonPath("visibility", is(equalTo(dataEntity.getVisibility().toString()))));
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:27,代码来源:DataControllerTest.java

示例13: testUpdateDatasetGoodAuthentication

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Test
public void testUpdateDatasetGoodAuthentication() throws Exception {
    final DataEntity dataEntity = TestUtil.getDataEntity();
    dataEntity.setCategoryId(getDataCategoryEntity().getId());

    mapper.registerModule(new JavaTimeModule());
    final byte[] content = mapper.writeValueAsBytes(new DataInfo(dataEntity));

    when(securityContext.getAuthentication()).thenReturn(authentication);
    SecurityContextHolder.setContext(securityContext);
    when(authentication.getPrincipal()).thenReturn(claims);
    when(dataService.updateDataset(anyLong(), any(DataInfo.class), any(Claims.class))).thenReturn(dataEntity);

    mockMvc.perform(put(DataController.PATH + "/1")
            .contentType(MediaType.APPLICATION_JSON)
            .content(content))

            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))

            .andExpect(jsonPath("name", is(equalTo(dataEntity.getName()))))
            .andExpect(jsonPath("description", is(equalTo(dataEntity.getDescription()))))
            .andExpect(jsonPath("contributorId", is(equalTo(dataEntity.getContributorId()))))
            .andExpect(jsonPath("accessibility", is(equalTo(dataEntity.getAccessibility().toString()))))
            .andExpect(jsonPath("visibility", is(equalTo(dataEntity.getVisibility().toString()))));
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:27,代码来源:DataControllerTest.java

示例14: testSaveNewPublicUser

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Test
public void testSaveNewPublicUser() throws Exception {
    final DataPublicUserEntity dataPublicUserEntity = TestUtil.getDataPublicUserEntity();

    mapper.registerModule(new JavaTimeModule());
    final byte[] content = mapper.writeValueAsBytes(new DataPublicUserInfo(dataPublicUserEntity));

    when(dataService.createPublicUser(any(DataPublicUserInfo.class))).thenReturn(dataPublicUserEntity);

    mockMvc.perform(post(DataController.PATH + "/public/users")
            .contentType(MediaType.APPLICATION_JSON)
            .content(content))

            .andExpect(status().isCreated())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))

            .andExpect(jsonPath("fullName", is(equalTo(dataPublicUserEntity.getFullName()))))
            .andExpect(jsonPath("email", is(equalTo(dataPublicUserEntity.getEmail()))))
            .andExpect(jsonPath("jobTitle", is(equalTo(dataPublicUserEntity.getJobTitle()))))
            .andExpect(jsonPath("institution", is(equalTo(dataPublicUserEntity.getInstitution()))))
            .andExpect(jsonPath("country", is(equalTo(dataPublicUserEntity.getCountry()))));
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:23,代码来源:DataControllerTest.java

示例15: testRecipeDeserialization

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入依赖的package包/类
@Test
public void testRecipeDeserialization() throws Exception {
  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(new JavaTimeModule());
  mapper.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false);
  mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
  mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
  Duration tagExpiry = Duration.ofSeconds(10);

  LocationRecipe recipe = new LocationRecipe();
  recipe.setName("RECIPE");

  recipe.setType(RecipeType.LOCATION);
  recipe.setTagExpiryDuration(tagExpiry);

  String string = mapper.writeValueAsString(recipe);

  Recipe recipeDeserialized = mapper.readValue(string, Recipe.class);
  Assert.assertEquals("RECIPE", recipeDeserialized.getName());
  Assert.assertEquals(RecipeType.LOCATION, recipeDeserialized.getType());
  Assert.assertEquals(tagExpiry, recipeDeserialized.getTagExpiryDuration());
}
 
开发者ID:impinj,项目名称:itemsense-java,代码行数:23,代码来源:RecipeTest.java


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