我有一些final static Road
像这样声明的:
public static final Road street = new Road().setWidth(20).setRoadColour(0xAAAAAA).setRoadLengths(500, 100).setDiversity(0);
public static final Road junction = new Road().setWidth(60).setRoadColour(0x999999).setCustomGenerator(new JunctionGenerator());
public static final Road normalRoad = new Road().setWidth(30).setRoadColour(0x999999).setRoadLengths(1000, 2000).setDiversity(2).setChanceForTurn(0).setRoadChance(street, 1);
public static final Road motorway = new Road().setWidth(60).setRoadColour(0x0000FF).setRoadLengths(1000, 100000).setDiversity(1).setChanceForTurn(0).setRoadChance(normalRoad, 1);
我希望能够通过它的实例来获取道路的名称,例如-
我在想这个方法会是这样的
Road.street.getClass().fieldName();
这将返回我声明它的字段的名称。