Guava: Feature Request: EnumTable

Created on 14 Dec 2018  路  3Comments  路  Source: google/guava

Hi while i was trying to rewrite some of my code i noticed that i would need a Table Structure but with Enum as Row and Column Keys.

I think it might be done as HashBasedTable, but if possible i would try to write my own EnumBasedTable for this based on HashBasedTable with changed Factory.

And if that works i would like to add it as new Feature for guava if wanted.

P4 package=collect status=triaged type=addition

All 3 comments

/cc @lowasser

@Hanmac I guess, ArrayTable.create(Arrays.asList(MyEnum1.values()), Arrays.asList(MyEnum2.values()) should do, shouldn't it? It's not perfect for enums as this note says, but most users probably don't care.

@Maaartinus i need to test that out how that reacts.
currently i use a HashBasedTable

i was thinking of using like this inside the EnumBasedTable:

StandardTable(Maps.newEnumMap(MyEnum1.class()), new MySupplier(MyEnum2.class()))

while MySupplier would return a new EnumMap on the get method

I don't know which way would be better in terms of serialize, I think currently i don't use the table for serialize purposes.

Was this page helpful?
0 / 5 - 0 ratings