Last active
September 23, 2015 22:57
-
-
Save eugener/629298 to your computer and use it in GitHub Desktop.
Minimizing Table Model Maintenance
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 final class TableColumnDefinitionSupport { | |
public interface ITableColumDefinition { | |
String getTitle(); | |
} | |
private TableColumnDefinitionSupport() {} | |
public final static > getDefinition( Class cls, int index ) { | |
return cls.getEnumConstants()[index]; | |
} | |
public final static > String getTitle(T columnDef) { | |
return columnDef instanceof ITableColumDefinition? | |
((ITableColumDefinition)columnDef).getTitle(): enumToName(columnDef); | |
} | |
private static > String enumToName(T columnDef) { | |
return columnDef == null? null: | |
StringUtils.capitalize( columnDef.name().replace('_', ' ').toLowerCase()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment