Created
December 10, 2012 04:21
-
-
Save michael-galpin/4248363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ParcelableMessage<T extends MessageMicro> implements Parcelable { | |
public int messageType; | |
public byte[] protoBytes; | |
private T mProto; | |
public T getProto() { | |
if (mProto == null) { | |
mProto = getProto(this); | |
} | |
return mProto; | |
} | |
public static <T extends MessageMicro> T getProto(ParcelableMessage<T> response) { | |
switch (response.messageType) { | |
case ALPHA : | |
return (T) Alpha.AlphaParser.parse(response.protoBytes); | |
case BETA : | |
return (T) Beta.BetaParser.parse(response.protoBytes); | |
default : | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment