I have a multilevel map requirement and I am using Guava Table . More precisely HashBasedTable.
Since my code needs a lot of custom processing on this dataset I would like to implement a derived class e.g. EventActionRuleTable which holds a map of Event - Action objects against a source.
something like this
HashMap<Source , Map<Event, Action> ruleMap ;
I am replacing the above with a
Table<Source, Event , Action> ruleTable = HashBasedTable.create();
But to hold all my custom code I would like to subclass HashBasedTable and figured its simply not possible.
Thus I choose to go with a delegate i.e.
public EventActionRule extends Table<Source, Event, Action>{
private HashBasedTable<Source, Event, Action> backup = null ;
public HashBasedTable<Source, Event, Action> getBackupTable() {
if (backupTable == null) {
backupTable = HashBasedTable.create() ;
}
return backupTable;
}
@Override
public boolean isEmpty() {
return getBackupTable().isEmpty();
}
/**
All other methods of Table interface overridden to delegate calls to backup instance
*/
....
}
Is this approach correct ? Can you list issues if its not ? Any alternative approach ?
Is HashBasedTable Gwt serialization compatible ? I am asking since the two backup maps used internally in the HashBasedTable are annotated with @GwtTransient annotation.