samples/growingparameters/src-api2.0/api/request/response/Compute.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:53:38 +0200
changeset 78 af48bccb02cb
child 192 78bf0774975d
permissions -rw-r--r--
Finished re-reading of "classes vs. interfaces"
jtulach@78
     1
package api.request.response;
jtulach@78
     2
jtulach@78
     3
import java.util.List;
jtulach@78
     4
import java.util.Map;
jtulach@78
     5
jtulach@78
     6
// BEGIN: grow.request.response
jtulach@78
     7
public interface Compute {
jtulach@78
     8
    public void computeData(Request request, Response response);
jtulach@78
     9
    
jtulach@78
    10
    public final class Request {
jtulach@78
    11
        // only getters public, rest hidden only for friend code
jtulach@78
    12
        Request() {
jtulach@78
    13
        }
jtulach@78
    14
    }
jtulach@78
    15
    
jtulach@78
    16
    public final class Response {
jtulach@78
    17
        // only setters public, rest available only for friend code
jtulach@78
    18
        private final Map<String,String> result;
jtulach@78
    19
        /** Allow access only to friend code */
jtulach@78
    20
        Response(Map<String,String> result) {
jtulach@78
    21
            this.result = result;
jtulach@78
    22
        }
jtulach@78
    23
        
jtulach@78
    24
        public void add(String s) {
jtulach@78
    25
            this.result.put(s, s);
jtulach@78
    26
        }
jtulach@78
    27
        
jtulach@78
    28
        public void addAll(List<String> all) {
jtulach@78
    29
            for (String s : all) {
jtulach@78
    30
                add(s);
jtulach@78
    31
            }
jtulach@78
    32
        }
jtulach@78
    33
jtulach@78
    34
        /** @since 2.0 */
jtulach@78
    35
        public void add(String s, String description) {
jtulach@78
    36
            this.result.put(s, description);
jtulach@78
    37
        }
jtulach@78
    38
    }
jtulach@78
    39
}
jtulach@78
    40
// END: grow.request.response