@Mapping(from = VmPayload.class, to = Payload.class) public static Payload map(VmPayload entity, Payload template) { if (entity.getDeviceType() != null || entity.getFiles().isEmpty()) { Payload model = template != null ? template : new Payload(); if (entity.getDeviceType() != null) { org.ovirt.engine.api.model.VmDeviceType deviceType = map(entity.getDeviceType(), null); if (deviceType != null) { model.setType(deviceType); } } model.setVolumeId(entity.getVolumeId()); if (entity.getFiles().size() > 0) { model.setFiles(new Files()); for (Map.Entry<String, String> entry : entity.getFiles().entrySet()) { File file = new File(); file.setName(entry.getKey()); file.setContent(entry.getValue()); model.getFiles().getFiles().add(file); } } return model; } return null; }
to.setContent(from.getContent());