In Java, the template selection process is dictated by the object-oriented programming model. When a data type T consisting of several different forms of data is represented by a composite class hierarchy, each method m defined on T must be defined in the class T corresponding to T. If the behavior of M depends on the form of the data type T, the method definition for m in T is abstract. In this case, each concrete subclass of T must provide a definition for m. This decomposition corresponds to the cond template used to process (non-recursive) mixed data in Scheme. Moreover, the relevant data values for each definition of m is simply the parameters of maugmented by the object fields in the class containing m!
The only features in the template for a Java method definition that are not dictated by the object-oriented programming model are the recursive method calls corresponding to circular references in the data definition. For any method m in a class C containing a object field f of type T where T is a supertype of C (e.g. C is a concrete class in a composite class hierarchy with T at the top), the body of m will usually invoke m recursively on each such field f. These recursive calls appear in the template. For a concrete example, see Section 1.6.2.