/** * Append specified delegate to the end of the delegate chain * * @param delegate * @return */ private InputEvent append(InputEvent delegate) { InputEvent tail = this; // Start here while (tail.next != null) // Find the end of the chain tail = tail.next; tail.next = delegate; // Append the new delegate return this; // Return the start of the delegate chain (eg. this node) }
/** * Link this delegate to the specified delegate and return the start of the delegate chain * * @param chain delegate to link to (will be null if the chain is empty) * @return */ InputEvent link(InputEvent chain) { if (chain == null) return this; // Chain is empty, return self return chain.append(this); // Append self to the start of the chain }