samples/instanceofclass/src-api1.0/api/InstanceProvider.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 10:04:53 +0200
changeset 210 acf2c31e22d4
parent 209 1c999569643b
permissions -rw-r--r--
Merge: Geertjan's changes to the end of the chapter
     1 
     2 package api;
     3 
     4 // BEGIN: instanceof.class.InstanceProvider1
     5 
     6 import java.util.concurrent.Callable;
     7 
     8 public final class InstanceProvider {
     9     private final Callable<Object> instance;
    10 
    11     public InstanceProvider(Callable<Object> instance) {
    12         this.instance = instance;
    13     }
    14     
    15     public Class<?> instanceClass() throws Exception {
    16         return instance.call().getClass();
    17     }
    18     public Object instanceCreate() throws Exception {
    19         return instance.call();
    20     }
    21 }
    22 // END: instanceof.class.InstanceProvider1