/** Returns a the next <code>DataProcessor</code> of type <code>predecClass</code> which precedes <code>dp</code> * * @param dp data processor * @param <T> predecessor class type * @param predecClass predecessor class * * @return frontend processor **/ public static <T extends DataProcessor> T getFrontEndProcessor(DataProcessor dp, Class<T> predecClass) { while (!predecClass.isInstance(dp)) { if (dp instanceof FrontEnd) dp = ((FrontEnd) dp).getLastDataProcessor(); else dp = dp.getPredecessor(); if (dp == null) return null; } return predecClass.cast(dp); } }
/** * Returns a description of this FrontEnd in the format: <front end name> {<DataProcessor1>, <DataProcessor2> ... * <DataProcessorN>} * * @return a description of this FrontEnd */ @Override public String toString() { if (last == null) return super.toString() + " {}"; LinkedList<DataProcessor> list = new LinkedList<DataProcessor>(); for (DataProcessor current = last; current != null; current = current.getPredecessor()) list.addFirst(current); // add processors in their correct order StringBuilder description = new StringBuilder(super.toString()).append(" {"); for (DataProcessor dp : list) description.append(dp).append(", "); description.setLength(description.length() - 2); return description.append('}').toString(); }
/** Returns a the next <code>DataProcessor</code> of type <code>predecClass</code> which precedes <code>dp</code> * * @param dp data processor * @param <T> predecessor class type * @param predecClass predecessor class * * @return frontend processor **/ public static <T extends DataProcessor> T getFrontEndProcessor(DataProcessor dp, Class<T> predecClass) { while (!predecClass.isInstance(dp)) { if (dp instanceof FrontEnd) dp = ((FrontEnd) dp).getLastDataProcessor(); else dp = dp.getPredecessor(); if (dp == null) return null; } return predecClass.cast(dp); } }
/** * Returns a description of this FrontEnd in the format: <front end name> {<DataProcessor1>, <DataProcessor2> ... * <DataProcessorN>} * * @return a description of this FrontEnd */ @Override public String toString() { if (last == null) return super.toString() + " {}"; LinkedList<DataProcessor> list = new LinkedList<DataProcessor>(); for (DataProcessor current = last; current != null; current = current.getPredecessor()) list.addFirst(current); // add processors in their correct order StringBuilder description = new StringBuilder(super.toString()).append(" {"); for (DataProcessor dp : list) description.append(dp).append(", "); description.setLength(description.length() - 2); return description.append('}').toString(); }