我有几个符合常见界面的枚举:
interface TableColumns
{
String getColumnName();
int getColumnIndex();
ColumnType getColumnType();
boolean isEditable();
int getColumnWidth();
}
Run Code Online (Sandbox Code Playgroud)
典型的实现是:
enum PointsTableColumns implements TrendTableColumns
{
POINTS_COLUMN("points_column", false, ColumnType.TEXT, 400, 0);
private String columnName;
private boolean editable;
private ColumnType columnType;
private int columnWidth;
private int columnIndex;
private PointsTableColumns (String columnName, boolean editable, ColumnType columnType,
int columnWidth,
int columnIndex)
{
this.columnName = columnName;
this.editable = editable;
this.columnType = columnType;
this.columnWidth = columnWidth;
this.columnIndex = columnIndex;
}
public boolean isEditable()
{
return editable;
}
public int getColumnIndex() …Run Code Online (Sandbox Code Playgroud) 我在做天体物理研究.我写了一个包含Star,Band和Datfile类的包.我也有枚举类型的BandName.每个星都包含几个Band,每个Band包含几个Datfiles.
我有几个星系的观测数据.对于其中的每一个,我创建了一个StarDatabase类(一个HashMap of Stars)和一个Main类.
我遇到的问题是使用枚举类型的BandName.到目前为止,我使用的所有数据都在I和V波段.现在我有J,H和K波段的数据.如果我只是简单地将J,H和K添加到BandName,那么迭代BandName中所有项目并执行某些操作的所有循环现在都会被破坏.
有任何想法吗?
编辑:总结我的问题,我希望每个包都有自己的BandName枚举,它可以迭代.但这不起作用,因为Star包中的方法期望Star.BandName类型的对象,我提供的类型为IndividualPackage.BandName的对象.