Reputation: 199
I have an object that I'm serializing to make requests.
private static final String JSON_REQUEST_ID = "requestId";
private static final String JSON_OBJECT_ID = "objectId";
private static final String JSON_GROUP_ID = "groupID";
@SerializedName(JSON_REQUEST_ID)
public String requestId;
@SerializedName(JSON_OBJECT_ID)
public String objectId;
@SerializedName(JSON_GROUP_ID)
public String groupId;
When I send this data off to be processed the objectId
and groupId
need to be exclusive. So if I set the objectId
I must remove the groupId
, and vice-versa, from the request.
Is there an easy way to annotate that or should I create a different class for each?
Upvotes: 0
Views: 67
Reputation: 446
Using different classes would make it more obvious, since different outcome (different attributes) mean different json objects.
For "simplification" on your side, you can use the same java class and provide a custom serializer for this.
Upvotes: 1