In Java, much of the template selection process is mandated 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 abstract class T corresponding to T. With a few rare exceptions, the method definition for m in T must be abstract, forcing each concrete subclass of T to 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 for each definition of m is simply the set of 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.7.2.