コード例 #1
0
  public RideDto entityToDto(Ride entity, Converter parent) {
    if (entity == null) {
      return null;
    }

    RideDto dto = new RideDto();

    dto.setId(entity.getId());
    dto.setStartTime(entity.getStartTime());
    dto.setEndTime(entity.getEndTime());
    dto.setTachometerStart(entity.getTachometerStart());
    dto.setTachometerEnd(entity.getTachometerEnd());
    dto.setDescription(entity.getDescription());

    EmployeeConverter ec = ConverterContainer.getEmployeeConverter();
    VehicleConverter vc = ConverterContainer.getVehicleConverter();
    if (!(parent == ec)) {
      dto.setEmployee(ec.entityToDto(entity.getEmployee(), this));
    }
    if (!(parent == vc)) {
      dto.setVehicle(vc.entityToDto(entity.getVehicle(), this));
    }

    return dto;
  }
コード例 #2
0
  public Ride dtoToEntity(RideDto dto, Converter parent) {
    if (dto == null) {
      return null;
    }

    Ride entity = new Ride();

    entity.setId(dto.getId());
    entity.setStartTime(dto.getStartTime());
    entity.setEndTime(dto.getEndTime());
    entity.setTachometerStart(dto.getTachometerStart());
    entity.setTachometerEnd(dto.getTachometerEnd());
    entity.setDescription(dto.getDescription());

    EmployeeConverter ec = ConverterContainer.getEmployeeConverter();
    VehicleConverter vc = ConverterContainer.getVehicleConverter();
    if (!(parent == ec)) {
      entity.setEmployee(ec.dtoToEntity(dto.getEmployee(), this));
    }
    if (!(parent == vc)) {
      entity.setVehicle(vc.dtoToEntity(dto.getVehicle(), this));
    }

    return entity;
  }