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 tools.gsf.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 AssetNameImpl implements AssetName {
26  
27      private final String type;
28      private final String name;
29  
30      /**
31       * @param type asset type
32       * @param name asset name
33       */
34      public AssetNameImpl(final String type, final String name) {
35          this.type = type;
36          this.name = name;
37      }
38  
39      /**
40       * @return the type
41       */
42      public String getType() {
43          return type;
44      }
45  
46      /**
47       * @return the name
48       */
49      public String getName() {
50          return name;
51      }
52  
53      /*
54       * (non-Javadoc)
55       *
56       * @see java.lang.Object#toString()
57       */
58      @Override
59      public String toString() {
60          return type + ":" + name;
61      }
62  
63      @Override
64      public boolean equals(Object o) {
65          if (this == o) {
66              return true;
67          }
68          if (o == null || getClass() != o.getClass()) {
69              return false;
70          }
71  
72          AssetNameImpl assetName = (AssetNameImpl) o;
73  
74          if (type != null ? !type.equals(assetName.type) : assetName.type != null) {
75              return false;
76          }
77          return name != null ? name.equals(assetName.name) : assetName.name == null;
78  
79      }
80  
81      @Override
82      public int hashCode() {
83          int result = type != null ? type.hashCode() : 0;
84          result = 31 * result + (name != null ? name.hashCode() : 0);
85          return result;
86      }
87  }