samples/instanceofclass/src-api1.0/api/InstanceProvider.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 10:03:34 +0200
changeset 191 c8a7c6621b5f
parent 75 aa07c59612ac
child 209 1c999569643b
permissions -rw-r--r--
Jesse wanted to have better example of InstanceProvider. Done, but it is also more complicated: http://wiki.apidesign.org/index.php/A_Method_Addition_Lover's_Heaven
jtulach@75
     1
jtulach@75
     2
package api;
jtulach@75
     3
jtulach@75
     4
// BEGIN: instanceof.class.InstanceProvider1
jtulach@191
     5
jtulach@191
     6
import java.util.concurrent.Callable;
jtulach@191
     7
jtulach@75
     8
public final class InstanceProvider {
jtulach@191
     9
    private final Callable<Object> instance;
jtulach@75
    10
jtulach@191
    11
    public InstanceProvider(Callable<Object> instance) {
jtulach@75
    12
        this.instance = instance;
jtulach@75
    13
    }
jtulach@75
    14
    
jtulach@191
    15
    public Class<?> instanceClass() throws Exception {
jtulach@191
    16
        return instance.call().getClass();
jtulach@75
    17
    }
jtulach@191
    18
    public Object instanceCreate() throws Exception {
jtulach@191
    19
        return instance.call();
jtulach@75
    20
    }
jtulach@75
    21
}
jtulach@75
    22
// END: instanceof.class.InstanceProvider1