@Bean public ModelMapper modelMapper() { ModelMapper modelMapper = new ModelMapper(); try { modelMapper.getConfiguration().setAmbiguityIgnored(true); Converter<Optional<LocalDate>, LocalDate> toLocalDate = ctx -> ctx.getSource() == null ? null : ctx.getSource().orElse(null); modelMapper.addConverter(toLocalDate); Converter<Optional<StandardId>, String> toIdString = ctx -> ctx.getSource() == null ? null : ctx.getSource().map(StandardId::getValue).orElse(null); modelMapper.addConverter(toIdString); TypeMap<FxVanillaOption, FxVanillaOptionDto> typeMap = modelMapper.createTypeMap(FxVanillaOption.class, FxVanillaOptionDto.class); typeMap.addMapping(src -> src.getExpiryZone().getId(), FxVanillaOptionDto::setExpiryZone); } catch (Exception e) { e.printStackTrace(); }
return modelMapper; }
public <V> void map(SourceGetter<S> sourceGetter, DestinationSetter<D, V> destinationSetter) { PropertyReferenceCollector collector = new PropertyReferenceCollector(typeMap.configuration, options);
S source = ProxyFactory.proxyFor(typeMap.getSourceType(), collector.newSourceInterceptor(), collector.getErrors()); sourceGetter.get(source);
D destination = ProxyFactory.proxyFor(typeMap.getDestinationType(), collector.newDestinationInterceptor(), collector.getErrors()); destinationSetter.accept(destination, destinationValue(destinationSetter));
typeMap.addMapping(collector.collect()); }
java.lang.NullPointerException at com.derivativepath.analytics.AnalyticsFxServiceApplication.lambda$3(AnalyticsFxServiceApplication.java:54) at org.modelmapper.internal.ReferenceMapExpressionImpl.map(ReferenceMapExpressionImpl.java:52) at org.modelmapper.internal.TypeMapImpl.addMapping(TypeMapImpl.java:231) at com.derivativepath.analytics.AnalyticsFxServiceApplication.modelMapper(AnalyticsFxServiceApplication.java:54)
--
You received this message because you are subscribed to the Google Groups "modelmapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modelmapper+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to modelmapper...@googlegroups.com.