View Javadoc
1   /*
2    * Copyright 2011 FatWire Corporation. All Rights Reserved.
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 com.fatwire.gst.foundation.mapping;
17  
18  /**
19   * Class that holds asset type and asset name, similar to AssetId.
20   * 
21   * @author Dolf Dijkstra
22   * @since Apr 13, 2011
23   * @see com.fatwire.assetapi.data.AssetId
24   */
25  public final class AssetName {
26  
27      private final String type;
28      private final String name;
29  
30      /**
31       * @param type
32       * @param name
33       */
34      public AssetName(final String type, final String name) {
35          super();
36          this.type = type;
37          this.name = name;
38      }
39  
40      /**
41       * @return the type
42       */
43      public String getType() {
44          return type;
45      }
46  
47      /**
48       * @return the name
49       */
50      public String getName() {
51          return name;
52      }
53  
54      /*
55       * (non-Javadoc)
56       * 
57       * @see java.lang.Object#toString()
58       */
59      @Override
60      public String toString() {
61          return type + ":" + name;
62      }
63  
64      /*
65       * (non-Javadoc)
66       * 
67       * @see java.lang.Object#hashCode()
68       */
69      @Override
70      public int hashCode() {
71          final int prime = 31;
72          int result = 1;
73          result = prime * result + (name == null ? 0 : name.hashCode());
74          result = prime * result + (type == null ? 0 : type.hashCode());
75          return result;
76      }
77  
78      /*
79       * (non-Javadoc)
80       * 
81       * @see java.lang.Object#equals(java.lang.Object)
82       */
83      @Override
84      public boolean equals(final Object obj) {
85          if (this == obj) {
86              return true;
87          }
88          if (obj == null) {
89              return false;
90          }
91          if (!(obj instanceof AssetName)) {
92              return false;
93          }
94          final AssetName other = (AssetName) obj;
95          if (name == null) {
96              if (other.name != null) {
97                  return false;
98              }
99          } else if (!name.equals(other.name)) {
100             return false;
101         }
102         if (type == null) {
103             if (other.type != null) {
104                 return false;
105             }
106         } else if (!type.equals(other.type)) {
107             return false;
108         }
109         return true;
110     }
111 
112 }