Java Code Examples for com.fatboyindustrial.gsonjavatime.Converters

The following examples show how to use com.fatboyindustrial.gsonjavatime.Converters. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OpenIoE   Source File: MqttConsumerThread.java    License: Apache License 2.0 5 votes vote down vote up
public MqttConsumerThread(SensorRepository sensorRepository, SensorDataRepositoryService databaseService, IoeConfiguration ioeConfiguration, SubscriptionRepository subscriptionRepository) {
    this.ioeConfiguration = ioeConfiguration;
    this.subscriptionRepository = subscriptionRepository;
    this.sensorRepository = sensorRepository;
    this.databaseService = databaseService;
    gson = Converters.registerAll(new GsonBuilder()).create();
}
 
Example 2
@Override
public void afterPropertiesSet() {
  GsonBuilder builder = new GsonBuilder();
  if (this.serializeNulls) {
    builder.serializeNulls();
  }
  if (this.prettyPrinting) {
    builder.setPrettyPrinting();
  }
  if (this.disableHtmlEscaping) {
    builder.disableHtmlEscaping();
  }
  if (this.dateFormatPattern != null) {
    builder.setDateFormat(this.dateFormatPattern);
  }
  if (this.typeAdapterFactoryList != null) {
    typeAdapterFactoryList.forEach(builder::registerTypeAdapterFactory);
  }
  if (this.typeAdapterHierarchyFactoryMap != null) {
    typeAdapterHierarchyFactoryMap.forEach(builder::registerTypeHierarchyAdapter);
  }
  if (this.registerJavaTimeConverters) {
    Converters.registerInstant(builder);
    Converters.registerLocalDate(builder);
  }
  this.gson = builder.create();
}
 
Example 3
Source Project: OpenIoE   Source File: BrokerMessageListener.java    License: Apache License 2.0 4 votes vote down vote up
public BrokerMessageListener(SensorRepository sensorRepository, SensorDataRepositoryService databaseService) {
    this.sensorRepository = sensorRepository;
    this.databaseService = databaseService;
    gson = Converters.registerAll(new GsonBuilder()).create();
}