本文整理汇总了Java中org.dozer.loader.api.FieldsMappingOptions类的典型用法代码示例。如果您正苦于以下问题:Java FieldsMappingOptions类的具体用法?Java FieldsMappingOptions怎么用?Java FieldsMappingOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldsMappingOptions类属于org.dozer.loader.api包,在下文中一共展示了FieldsMappingOptions类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ConverterUtil
import org.dozer.loader.api.FieldsMappingOptions; //导入依赖的package包/类
/**
* Constructor.
*
* @param dozerTypeConverter custom dozer converter for types
*/
public ConverterUtil(@Nonnull @NonNull final DozerTypeConverter dozerTypeConverter) {
final DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
final BeanMappingBuilder builder = new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(FieldDto.class, FieldInfo.class)
.fields("type", "type", FieldsMappingOptions.customConverterId("typeConverter"))
.fields("partition_key", "partitionKey", FieldsMappingOptions.copyByReference())
.fields("source_type", "sourceType", FieldsMappingOptions.copyByReference());
mapping(TableDto.class, TableInfo.class)
.fields("name", "name", FieldsMappingOptions.copyByReference());
mapping(DatabaseDto.class, DatabaseInfo.class)
.fields("name", "name", FieldsMappingOptions.copyByReference());
mapping(PartitionDto.class, PartitionInfo.class)
.fields("name", "name", FieldsMappingOptions.copyByReference());
mapping(AuditDto.class, AuditInfo.class);
mapping(StorageDto.class, StorageInfo.class);
}
};
dozerBeanMapper.addMapping(builder);
final Map<String, CustomConverter> customConverterMap = Maps.newHashMap();
customConverterMap.put("typeConverter", dozerTypeConverter);
dozerBeanMapper.setCustomConvertersWithId(customConverterMap);
this.mapper = dozerBeanMapper;
}
示例2: configure
import org.dozer.loader.api.FieldsMappingOptions; //导入依赖的package包/类
@Override
protected void configure() {
mapping(User.class, TwitterSubscriptionData.class, oneWay())
.fields("url", "url", FieldsMappingOptions.customConverter(TwitterUserUrlCustomConverter.class));
mapping(User.class, TwitterProfileData.class, oneWay())
.fields("url", "url", FieldsMappingOptions.customConverter(TwitterUserUrlCustomConverter.class));
}
示例3: init
import org.dozer.loader.api.FieldsMappingOptions; //导入依赖的package包/类
@Before
public void init() throws CamundaRestException, InterruptedException {
processEngine = processEngineRule.getProcessEngine();
processEngine.getRuntimeService()
.startProcessInstanceByKey(
"Simple_Process"
, ImmutableMap.of("stringVar", "string", "otherVar", "other string")
);
Mockito.when(externalTaskRestService.fetchAndLock(Mockito.any(FetchExternalTasksDto.class))).then((invocation) -> {
FetchExternalTasksDto arg = invocation.getArgumentAt(0, FetchExternalTasksDto.class);
BeanMappingBuilder mappingBuilder = new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(LockedExternalTask.class, LockedExternalTaskDto.class)
.fields("variables"
, new FieldDefinition("variables").accessible()
, FieldsMappingOptions.customConverter(VarConverter.class));
}
};
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.addMapping(mappingBuilder);
return arg.getTopics()
.stream()
.flatMap(topic -> processEngine.getExternalTaskService()
.fetchAndLock(arg.getMaxTasks(), arg.getWorkerId())
.topic(topic.getTopicName(), topic.getLockDuration())
.variables(new ArrayList<>(topic.getVariables()))
.execute()
.stream()
.map(task -> mapper.map(task, LockedExternalTaskDto.class))
)
.collect(Collectors.toList());
});
FetchExternalTasksDto.FetchExternalTaskTopicDto topicDto = new FetchExternalTasksDto.FetchExternalTaskTopicDto();
topicDto.setLockDuration(10000);
topicDto.setTopicName("simpleCommand");
topicDto.setVariables(Arrays.asList("stringVar", "otherVar"));
Mockito.when(manager.getExternalTaskTopics(Mockito.anyLong())).thenReturn(Collections.singletonList(topicDto));
Mockito.when(manager.toCommand(Mockito.any())).thenReturn(new Command());
processor = new ExternalTaskProcessor();
JavaUtils.setFieldWithoutCheckedException(
ReflectionUtils.findField(ExternalTaskProcessor.class, "externalTaskService")
, processor
, externalTaskRestService
);
JavaUtils.setFieldWithoutCheckedException(
ReflectionUtils.findField(ExternalTaskProcessor.class, "taskManager")
, processor
, manager
);
JavaUtils.setFieldWithoutCheckedException(
ReflectionUtils.findField(ExternalTaskProcessor.class, "taskSender")
, processor
, sender
);
}
示例4: configure
import org.dozer.loader.api.FieldsMappingOptions; //导入依赖的package包/类
@Override
protected void configure() {
mapping(GitRepository.class, GitRepositoryData.class, oneWay())
.fields("languagesUrl", "languages", FieldsMappingOptions
.customConverterId(GitRepoLanguagesCustomConverter.class.getSimpleName()));
}
示例5: addDTOMapping
import org.dozer.loader.api.FieldsMappingOptions; //导入依赖的package包/类
private static <E extends Entity, D extends DTO> List<BeanMappingBuilder> addDTOMapping(final Class<E> entityClass, final Class<D> dtoClass,
IsMappingMode[] modes) {
final ArrayList<BeanMappingBuilder> builders = new ArrayList<>();
// For each enum value, builds a custom mapping.
if (modes != null) {
for (final IsMappingMode mode : modes) {
final BeanMappingBuilder builder = new BeanMappingBuilder() {
@Override
protected void configure() {
// Basic mapping options.
final TypeMappingOption[] basicOptions = new TypeMappingOption[] {
TypeMappingOptions.oneWay(),
TypeMappingOptions.wildcard(true),
TypeMappingOptions.mapNull()
};
// Mapping builder.
// The Dozer map-id attribute is the getMapId() method of the enum value.
final TypeMappingBuilder tmb = mapping(entityClass, dtoClass, ArrayUtils.add(basicOptions, TypeMappingOptions.mapId(mode.getMapId())));
// Custom fields.
if (mode.getCustomFields() != null) {
for (final CustomMappingField custom : mode.getCustomFields()) {
final IsMappingMode customFieldMappingMode = custom.getMappingMode();
if (customFieldMappingMode != null) {
tmb.fields(custom.getEntityAttributeName(), custom.getDTOMapKey(), FieldsMappingOptions.useMapId(customFieldMappingMode.getMapId()));
} else {
tmb.fields(custom.getEntityAttributeName(), custom.getDTOMapKey());
}
}
}
// Excluded fields.
if (mode.getExcludedFields() != null) {
for (final MappingField excluded : mode.getExcludedFields()) {
tmb.exclude(excluded.getEntityAttributeName());
}
}
}
};
builders.add(builder);
}
}
return builders;
}