01: package com.jofti.util;
02:
03: /*
04:
05: An amended version of the ObjectProcedure Interface from the CERN COLT project.
06:
07:
08: Copyright © 1999 CERN - European Organization for Nuclear Research.
09:
10: Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
11:
12: is hereby granted without fee, provided that the above copyright notice appear in all copies and
13:
14: that both that copyright notice and this permission notice appear in supporting documentation.
15:
16: CERN makes no representations about the suitability of this software for any purpose.
17:
18: It is provided "as is" without expressed or implied warranty.
19:
20: */
21:
22: /**
23:
24: * Interface that represents a procedure object: a procedure that takes
25:
26: * a single or pair of arguments and does not return a value.
27:
28: */
29:
30: public interface ObjectProcedure {
31:
32: /**
33:
34: * Applies a procedure to an argument.
35:
36: * Optionally can return a boolean flag to inform the object calling the procedure.
37:
38: *
39:
40: * <p>Example: forEach() methods often use procedure objects.
41:
42: * To signal to a forEach() method whether iteration should continue normally or terminate (because for example a matching element has been found),
43:
44: * a procedure can return <tt>false</tt> to indicate termination and <tt>true</tt> to indicate continuation.
45:
46: *
47:
48: * @param element element passed to the procedure.
49:
50: * @return a flag to inform the object calling the procedure.
51:
52: */
53:
54: abstract public boolean apply(Object element);
55:
56: /**
57:
58: * Applies a procedure to an argument.
59:
60: * Optionally can return a boolean flag to inform the object calling the procedure.
61:
62: *
63:
64: * <p>Example: forEach() methods often use procedure objects.
65:
66: * To signal to a forEach() method whether iteration should continue normally or terminate (because for example a matching element has been found),
67:
68: * a procedure can return <tt>false</tt> to indicate termination and <tt>true</tt> to indicate continuation.
69:
70: *
71:
72: * @param key the key passed to the procedure.
73: *
74: * @param element element passed to the procedure.
75:
76: * @return a flag to inform the object calling the procedure.
77:
78: */
79:
80: abstract public boolean apply(Object key, Object element);
81:
82: }
|