I have a set information that I am able to read in as raw data which corresponds to different physical quantities depending on which device provided that information. Every device contains the same amount of data and the same types, just different fields are interpreted differently. Here's how I have implemented it so far:public abstract class SuperData {    int voltage1;    int voltage2;    SuperData(int v1, int v2) {        voltage1 = v1;        voltage2 = v2;    }    public int getVoltage1 { return voltage1; }    public int getVoltage2 { return voltage2; }}public class CarAData extends SuperData {    CarAData(int v1, int v2) { super(v1, v2); }    public int getKeyVoltage { return getVoltage1(); }    public int getLightVoltage { return getVoltage2(); }}public class CarBData extends SuperData {    CarAData(int v1, int v2) { super(v1, v2); }    public int getStarterVoltage { return getVoltage1(); }    public int getCigarretteVoltage { return getVoltage2(); }}This is just a trivial example; in reality it is about 60 fields that are just a byte array coming over Bluetooth. I am using a factory to create the correct object based on another data stream but the problem is it requires the use of instanceof down the road to know which method to call. So what pattern is the best way to represent data which has different meanings?
What pattern should one use for multiple interpretations of the same data?
java;design patterns;polymorphism
You're describing a Variant Record or Discriminated Union.  They're not directly supported in Java, but as you've already discovered you can simulate them with class hierarchies.  instanceof shouldn't be a problem.  It's a bit of reflection voodoo, but you only have to do it once per record if you cast your object to the correct Type once you identify it.  If the reflection bothers you, include a 'Tag' method in the base class that returns a descriptor of some sort.It's too bad you're not working in C#; C-like Union structures are supported directly in that language.