class OrderedComposite<S> {

	private final List<S> unordered = new ArrayList<>();

	private final List<S> ordered = new ArrayList<>();

	private final Comparator<? super S> comparator = new AnnotationAwareOrderComparator();

	private final List<S> list = new ArrayList<>();

	/**
	 * Public setter for the listeners.
	 * @param items to set
	 */
	public void setItems(List<? extends S> items) {
		unordered.clear();
		ordered.clear();
		for (S s : items) {
			add(s);
		}
	}

	/**
	 * Register additional item.
	 * @param item to add
	 */
	public void add(S item) {<FILL_FUNCTION_BODY>}

	/**
	 * Public getter for the list of items. The {@link Ordered} items come first, followed
	 * by any unordered ones.
	 * @return an iterator over the list of items
	 */
	public Iterator<S> iterator() {
		return Collections.unmodifiableList(list).iterator();
	}

	/**
	 * Public getter for the list of items in reverse. The {@link Ordered} items come
	 * last, after any unordered ones.
	 * @return an iterator over the list of items
	 */
	public Iterator<S> reverse() {
		ArrayList<S> result = new ArrayList<>(list);
		Collections.reverse(result);
		return result.iterator();
	}

}

		if (item instanceof Ordered) {
			if (!ordered.contains(item)) {
				ordered.add(item);
			}
		}
		else if (AnnotationUtils.isAnnotationDeclaredLocally(Order.class, item.getClass())) {
			if (!ordered.contains(item)) {
				ordered.add(item);
			}
		}
		else if (!unordered.contains(item)) {
			unordered.add(item);
		}
		ordered.sort(comparator);
		list.clear();
		list.addAll(ordered);
		list.addAll(unordered);
	
<no_super_class>