View Javadoc
1   /*******************************************************************************
2    * Copyright 2012 pw999
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 net.sf.oqt.model;
17  
18  import java.io.Serializable;
19  import java.util.ArrayList;
20  import java.util.Collection;
21  
22  /**
23   * Models a JPA Entity.
24   * 
25   * @author phillip
26   * 
27   */
28  public class EntityVO implements Serializable, Comparable<EntityVO> {
29  
30      /**
31       * UID
32       */
33      private static final long serialVersionUID = 6569188216271256792L;
34  
35      private final String name;
36  
37      private final Collection<QueryVO> queries = new ArrayList<QueryVO>();
38  
39      public EntityVO(final String name) {
40          this.name = name;
41      }
42  
43      public final String getName() {
44          return name;
45      }
46  
47      public final Collection<QueryVO> getQueries() {
48          return queries;
49      }
50  
51      @Override
52      public int compareTo(final EntityVO o) {
53          return getName().compareToIgnoreCase(o.getName());
54      }
55  
56      @Override
57      public int hashCode() {
58          final int prime = 31;
59          int result = 1;
60          result = prime * result + ((name == null) ? 0 : name.hashCode());
61          return result;
62      }
63  
64      @Override
65      public boolean equals(final Object obj) {
66          if (obj instanceof EntityVO) {
67              return getName().equalsIgnoreCase(((EntityVO) obj).getName());
68          }
69          return super.equals(obj);
70      }
71  
72  
73      
74      
75  
76  }