-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathItemMapper.java
More file actions
32 lines (29 loc) · 955 Bytes
/
ItemMapper.java
File metadata and controls
32 lines (29 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ru.practicum.shareit.item;
import ru.practicum.shareit.item.dto.ItemDto;
import ru.practicum.shareit.item.model.Item;
public class ItemMapper {
public static ItemDto toItemDto(Item item) {
if (item == null) {
return null;
}
ItemDto dto = new ItemDto();
dto.setId(item.getId());
dto.setName(item.getName());
dto.setDescription(item.getDescription());
dto.setAvailable(item.getAvailable());
dto.setRequestId(item.getRequestId());
return dto;
}
public static Item toItem(ItemDto itemDto) {
if (itemDto == null) {
return null;
}
Item item = new Item();
item.setId(itemDto.getId());
item.setName(itemDto.getName());
item.setDescription(itemDto.getDescription());
item.setAvailable(itemDto.getAvailable());
item.setRequestId(itemDto.getRequestId());
return item;
}
}