Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:51:51+00:00 2026-06-14T07:51:51+00:00

I would like to create some model classes that implement Android’s Parcelable interface, but

  • 0

I would like to create some model classes that implement Android’s Parcelable interface, but I want the classes to be usable outside Android. I thought about implementing a wrapper for all these model classes (they are serialized in the same way, with Google Protocol Buffers internally), but I am not sure how to do it.

Say I have an interface Model, and an implementing class ModelImpl. Currently, Model extends Parcelable, but I would like to decouple Model and ModelImpl from Parcelable, and have a ParcelWrapper instead. Preferably, this should all be type safe and nice. Any pointers as to how to approach this problem?

If I come across a solution, I’ll post it here, of course.

Thanks! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:51:52+00:00Added an answer on June 14, 2026 at 7:51 am

    I ended up using the decorator pattern. So now I’ve got:

    • Model, the interface that defines the public methods I need.
    • ModelImpl, the actual implementing model class (which uses Google Protocol Buffers for serialisation)
    • ModelParcelDecorator, which implements Model and Parcelable, and takes an instance of an implementation of Model and stores it as reference, delegating all methods from the Model interface to this instance. ModelParcelDecorator uses the protocol buffers serialisation mechanism directly, so I don’t need to serialise into a Parcel and back manually.

    Model and ModelImpl can now reside in their own library, and be used outside Android.

    Unfortunately, I needed to write a decorator for each of my model classes, but this is the best solution I found until now. If I find something better, I will post it here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have authored some custom classes that I would like to create using XAML:
I would like to create some instance variables for my model subclass, but when
I would like to create a file which stores some data that can be
I would like to create a caching system that will bypass some mechanisms in
I need to create a few classes and would like some help on where
I would like to create some kind of structure to reduce the number of
I would like to create some buttons with dynamic width using CSS sprites and
I would like to create some sort of function where you pass in a
I'm working from a JavaScript book and would like to create some menus using
I create some dynamic textbox's and a button in a placeholder and would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.