55 phases = Collections.unmodifiableList(phases); 56 immutable = true; 57 } 58 } 59 60 /** 61 * Add a new phase at the beginning of this suite. 62 */ 63 public final void prependPhase(BasePhase<? super C> phase) { 64 phases.add(0, phase); 65 } 66 67 /** 68 * Add a new phase at the end of this suite. 69 */ 70 public final void appendPhase(BasePhase<? super C> phase) { 71 phases.add(phase); 72 } 73 74 /** 75 * Returns a {@link ListIterator} at the position of the first phase which is an instance of 76 * {@code phaseClass} or null if no such phase can be found. 77 * 78 * Calling {@link ListIterator#previous()} would return the phase that was found. 79 * 80 * @param phaseClass the type of phase to look for. 81 */ 82 public final ListIterator<BasePhase<? super C>> findPhase(Class<? extends BasePhase<? super C>> phaseClass) { 83 return findPhase(phaseClass, false); 84 } 85 86 /** 87 * Returns a {@link ListIterator} at the position of the first phase which is an instance of 88 * {@code phaseClass} or, if {@code recursive} is true, is a {@link PhaseSuite} containing a 89 * phase which is an instance of {@code phaseClass}. This method returns null if no such phase 90 * can be found. 91 * 92 * Calling {@link ListIterator#previous()} would return the phase or phase suite that was found. 93 * 94 * @param phaseClass the type of phase to look for | 55 phases = Collections.unmodifiableList(phases); 56 immutable = true; 57 } 58 } 59 60 /** 61 * Add a new phase at the beginning of this suite. 62 */ 63 public final void prependPhase(BasePhase<? super C> phase) { 64 phases.add(0, phase); 65 } 66 67 /** 68 * Add a new phase at the end of this suite. 69 */ 70 public final void appendPhase(BasePhase<? super C> phase) { 71 phases.add(phase); 72 } 73 74 /** 75 * Inserts a phase before the last phase in the suite. If the suite contains no phases the new 76 * phase will be inserted as the first phase. 77 */ 78 public final void addBeforeLast(BasePhase<? super C> phase) { 79 ListIterator<BasePhase<? super C>> last = findLastPhase(); 80 if (last.hasPrevious()) { 81 last.previous(); 82 } 83 last.add(phase); 84 } 85 86 /** 87 * Returns a {@link ListIterator} at the position of the last phase in the suite. If the suite 88 * has no phases then it will return an empty iterator. 89 */ 90 private ListIterator<BasePhase<? super C>> findLastPhase() { 91 ListIterator<BasePhase<? super C>> it = phases.listIterator(); 92 while (it.hasNext()) { 93 it.next(); 94 } 95 return it; 96 } 97 98 /** 99 * Returns a {@link ListIterator} at the position of the first phase which is an instance of 100 * {@code phaseClass} or null if no such phase can be found. 101 * 102 * Calling {@link ListIterator#previous()} would return the phase that was found. 103 * 104 * @param phaseClass the type of phase to look for. 105 */ 106 public final ListIterator<BasePhase<? super C>> findPhase(Class<? extends BasePhase<? super C>> phaseClass) { 107 return findPhase(phaseClass, false); 108 } 109 110 /** 111 * Returns a {@link ListIterator} at the position of the first phase which is an instance of 112 * {@code phaseClass} or, if {@code recursive} is true, is a {@link PhaseSuite} containing a 113 * phase which is an instance of {@code phaseClass}. This method returns null if no such phase 114 * can be found. 115 * 116 * Calling {@link ListIterator#previous()} would return the phase or phase suite that was found. 117 * 118 * @param phaseClass the type of phase to look for |