1   /*
2    * Copyright 2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */ 
16  package org.apache.commons.betwixt.schema;
17  
18  /***
19   * @author <a href='http://jakarta.apache.org/commons'>Jakarta Commons Team</a>, <a href='http://www.apache.org'>Apache Software Foundation</a>
20   */
21  public class LoopBean {
22      private static int count = 0;
23      
24      private static final int max_count = 100;
25  
26      private LoopBean friend;
27      
28      private String name;
29      
30      public LoopBean(String name) 
31      {
32          this.name = name;
33      }
34      
35      public LoopBean getFriend()
36      {
37          if (++count > max_count)
38          {
39              throw new RuntimeException("Looping!");
40          }
41          return friend;
42      }
43      
44      public void setFriend(LoopBean friend)
45      {
46          this.friend = friend;
47      }
48      
49      public String getName()
50      {
51          return name;
52      }
53      
54      public String toString()
55      {
56          return "[LoopBean] name=" + name;
57      }
58  
59  }