View Javadoc
1   /*
2    * Copyright (C) 2008 the original author or authors.
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  
17  package org.codehaus.plexus.metadata.ann;
18  
19  import org.objectweb.asm.Type;
20  
21  /**
22   * @author Eugene Kuleshov
23   */
24  public class AnnEnum {
25  
26      private final String desc;
27      private final String value;
28  
29      public AnnEnum(String desc, String value) {
30          this.desc = desc;
31          this.value = value;
32      }
33  
34      public String getDesc() {
35          return desc;
36      }
37  
38      public String getValue() {
39          return value;
40      }
41  
42      public String getType() {
43          return Type.getType(desc).getClassName();
44      }
45  
46      public int hashCode() {
47          return 31 * (31 + desc.hashCode()) + value.hashCode();
48      }
49  
50      public boolean equals(Object obj) {
51          if (this == obj) {
52              return true;
53          }
54          if (obj == null) {
55              return false;
56          }
57          if (getClass() != obj.getClass()) {
58              return false;
59          }
60          AnnEnum other = (AnnEnum) obj;
61          if (desc == null) {
62              if (other.desc != null) {
63                  return false;
64              }
65          } else if (!desc.equals(other.desc)) {
66              return false;
67          }
68          if (value == null) {
69              if (other.value != null) {
70                  return false;
71              }
72          } else if (!value.equals(other.value)) {
73              return false;
74          }
75          return true;
76      }
77  }