Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support auto conversion if field is renamed #48

Open
markusjura opened this issue Jul 21, 2020 · 0 comments
Open

Support auto conversion if field is renamed #48

markusjura opened this issue Jul 21, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@markusjura
Copy link
Contributor

teleproto tries to auto-convert based on field names. If the input/output object has the same structure but a field name has changed in one of the objects, a customer Reader or Writer needs to be defined, e.g.

    implicit val writerDomainV3: Writer[TripModel.Offer, domain.Offer] = {
      case offer: TripModel.Offer =>
        domain.Offer(
          offer.id,
          offer.serviceAreaUuid,
          Some(SeatInfo.domainWriterV3.write(offer.seatInfo)),
          Some(Price.priceWriterV3.write(offer.price)),
          offer.priceMetadata.map(PriceMetadata.domainWriterV3.write),
          Some(NamedLocation.domainWriterV3.write(offer.origin)),
          offer.walkToPickup.map(Walk.domainWriterV3.write),
          offer.pickupStop.map(Stop.domainWriterV3.write),
          offer.pickupArea.map(StopArea.writerDomainV3.write),
          Some(TimeRange.writerV3.write(offer.pickupTimeRange)),
          offer.deliveryStop.map(Stop.domainWriterV3.write),
          offer.deliveryArea.map(StopArea.writerDomainV3.write),
          offer.walkToDestination.map(Walk.domainWriterV3.write),
          Some(TimeRange.writerV3.write(offer.deliveryTimeRange)),
          Some(NamedLocation.domainWriterV3.write(offer.destination)),
          Some(InstantWriter.write(offer.requestTime)),
          offer.timeOffset.map(to => DurationWriter.write(to.toDuration))
        )
    }

It would be nice if teleproto could do auto conversion even if the field names are different. Maybe we can declare an annotation to tell teleproto how to map a field if names are different.

@joroKr21 joroKr21 added the enhancement New feature or request label Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants