http://localhost:8080/configurator
<dependency>
<groupId>org.modelmapper.extensions</groupId>
<artifactId>modelmapper-spring</artifactId>
<version>3.0.0</version>
</dependency>
public interface MapperService {
/**
* Note: outClass object must have default constructor with no arguments
*
* @param <D> type of result object.
* @param <T> type of source object to map from.
* @param entity entity that needs to be mapped.
* @param outClass class of result object.
* @return new object of <code>outClass</code> type.
*/
<D, T> D map(T entity, Class<D> outClass);
/**
* Note: outClass object must have default constructor with no arguments
*
* @param entityList list of entities that needs to be mapped
* @param outCLass class of result list element
* @param <D> type of objects in result list
* @param <T> type of entity in <code>entityList</code>
* @return list of mapped object with <code><D></code> type.
*/
<D, T> List<D> mapAll(Collection<T> entityList, Class<D> outCLass);
/**
* Maps {@code source} to {@code destination}.
*
* @param source object to map from
* @param destination object to map to
*/
<S, D> D map(S source, D destination);
}
@Service
@RequiredArgsConstructor
public class MapperServiceImpl implements MapperService {
private final ModelMapper modelMapper;
@Override
public <D, T> D map(final T entity, Class<D> outClass) {
return modelMapper.map(entity, outClass);
}
@Override
public <D, T> List<D> mapAll(final Collection<T> entityList, Class<D> outCLass) {
return entityList.stream().map(entity -> map(entity, outCLass)).collect(Collectors.toList());
}
@Override
public <S, D> D map(final S source, D destination) {
modelMapper.map(source, destination);
return destination;
}
}
Order order = mapperService.map(orderCreationRequest, Order.class);
OrderCreationResponse orderCreationResponse = mapperService.map(order, OrderCreationResponse.class);
public class Item {
private Order order;
Как с консоли считывать поисковый запрос
попробуйте: