What's the best way to represent this in Protocol Buffer (.proto)?
public class EntityId {
private String type;
private String id;
}
public class EntityBlob {
private String blobName;
private byte[] blobBytes;
}
public class Entity {
private String dir;
private String entityType;
private String entityId;
private Set<EntityBlob> blobs;
private Map<String,EntityProperty> properties;
private Multimap<String, EntityId> relatedEntities;
}
public abstract class EntityProperty<T> {
// ...
}
// Example concrete EntityProperty:
public class EntityStringProperty extends EntityProperty<String> {
public EntityStringProperty(String value) {
super(value);
}
}
Where the field properties can only accept the following, EntityStringProperty, EntityBooleanProperty, EntityDoubleProperty, etc.
With some special classes:
public class EntityArrayProperty extends EntityProperty<List<EntityProperty>> {
public EntityArrayProperty(List<EntityProperty> value) {
super(value);
}
}
public class EntityObjectProperty extends EntityProperty<Map<String, EntityProperty>> {
public EntityObjectProperty(Map<String, EntityProperty> value) {
super(value);
}
}
How can this complex classes can be modeled with Protocol Buffers? Specifically the Map<String,EntityProperty> properties?