/** * Get a rolling stock by type and road. Used to test that rolling stock with a specific type and * road exists. * * @param type RollingStock type. * @param road RollingStock road. * @return the first RollingStock found with the specified type and road. */ public RollingStock getByTypeAndRoad(String type, String road) { Enumeration<String> en = _hashTable.keys(); while (en.hasMoreElements()) { RollingStock rs = getById(en.nextElement()); if (rs.getTypeName().equals(type) && rs.getRoadName().equals(road)) { return rs; } } return null; }
/** * Return rolling stock of a specific type * * @param type type of rolling stock * @return list of RollingStock that are specific type */ public List<RollingStock> getByTypeList(String type) { List<RollingStock> typeList = getByTypeList(); List<RollingStock> out = new ArrayList<RollingStock>(); for (RollingStock rs : typeList) { if (rs.getTypeName().equals(type)) { out.add(rs); } } return out; }