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

  • SEARCH
  • Home
  • 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 6064661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:18:17+00:00 2026-05-23T09:18:17+00:00

I have different kinds of serializable ObjectState ‘s that store state data for important

  • 0

I have different kinds of serializable ObjectState‘s that store state data for important application objects. I do this so I can persist these important objects arcoss application instatances. The user will sometimes need to group certain objects together into containers, so some of the ObjectState‘s are placed into an array of ObjectState‘s and passed to a ContainerState (just a serializable class that holds an array of generic types serializables).

My question is, how do I de-serialize the ContianerState and keep type integrity? I thought I could try something like:

public static ContainerState<V> inflateState(V v, Serializable state) throws ClassCastException {
    return (ContainerState<V>)state;
}

But that won’t even get past Eclipses’ warning system. I also tried V.class to the same result. Is it even possible for me to achieve this?

EDIT 1:

I tried this, it seems to work, but I’m not sure if it’s the best way. Any thoughts?

public static <cls extends Serializable> ContainerState<cls> inflateState(Class<? extends Serializable> cls, Serializable state) throws ClassCastException {
    return (ContainerState<cls>)state;
}
  • 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-05-23T09:18:18+00:00Added an answer on May 23, 2026 at 9:18 am

    This should at least compile:

    public static <C extends Serializable> ContainerState<C> inflateState(Class<C> cls, Serializable state) throws ClassCastException {
        return (ContainerState<C>)state;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different kinds of objects that I'd like to live under the
I have a method that receives many different kinds of objects and decides what
I have an application that lends itself to an event/listener model. Several different kinds
In our e-commerce application, we have different kinds of products having different kinds of
Is this possible to have two (or more) different kinds of cells to be
You can have different naming convention for class members, static objects, global objects, and
I have different kinds of enumerations in this flavour class Gender extends Enumeration {
I have a Django application which allows different kinds of users: firms, administrators, external
I have a field in a table that I will be storing different kinds
I have two different kinds of objects: Ride and Location . A Ride has

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.