question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic Marshal creation from an existing entity

See original GitHub issue

I normally create database records by converting an AutoParcel entity into ContentValues. It would be nice to have Marshal class have a constructor that accepts an entity as a single argument. Or this could probably be solved by adding toContentValues method to Mapper.

Overall I feel like existing Marshal class is a complication, we already have builder pattern from AutoParcel, so it does not add much. We can make id nullable somehow so we will avoid the case when we can’t pass AutoParcel nullability issue with an id that does not exist yet.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
PaulWoitaschekcommented, Apr 20, 2016

Thanks for the hint! I ended with just each class having a method called contentValues() handling that so it stays an implementation detail.

That has the convenience of being very scoped.

@AutoValue public abstract class TrackInfo implements TrackInfoModel {

   // ...

   public static final Mapper<TrackInfo> MAPPER = new Mapper<>(AutoValue_TrackInfo::new);

   public ContentValues contentValues(long showId) {
      ContentValues cv = new TrackInfoMarshal<>(this).asContentValues();
      cv.remove(_ID);
      cv.put(SHOWID, showId);
      return cv;
   }
}
0reactions
AlecStrongcommented, Apr 20, 2016

you can create your own constructor which ignores the id

public class User implements UserModel {
  public class Marshal extends UserMarshal<Marshal> {
    public Marshal(User user) {
      super(user);
      contentValues.remove(USER_ID);
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Marshalling • Akka HTTP - Documentation
Marshalling is the process of converting a higher-level (object) structure into some kind of lower-level representation, often a “wire format”.
Read more >
Default Marshalling Behavior - .NET Framework
When a managed class is passed to COM, the interop marshaller automatically wraps the class with a COM proxy and passes the class...
Read more >
auraphp/Aura.Marshal: A data-marshaling toolset - GitHub
The Aura Marshal package is a data-object marshalling tool. It takes results from data sources and marshals those result sets into domain model...
Read more >
Marshalling (computer science) - Wikipedia
Marshalling is describing an intent or process to transfer some object from a client to server, intent is to have the same object...
Read more >
Top 7 tools to create an Entity Relationship Diagram (ERD ...
It's a great way to design a new relational database or make sense of and/or modify an existing one. Top 7 tools for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found