View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.datamodel.classifications2;
20  
21  import java.io.Serializable;
22  
23  import org.mycore.datamodel.metadata.MCRObjectID;
24  import org.mycore.datamodel.niofs.MCRPath;
25  
26  import jakarta.persistence.Basic;
27  import jakarta.persistence.Column;
28  import jakarta.persistence.Embeddable;
29  
30  /**
31   * @author Thomas Scheffler (yagee)
32   * 
33   * @version $Revision$ $Date$
34   * @since 2.0
35   */
36  @Embeddable
37  public class MCRCategLinkReference implements Serializable {
38  
39      private static final long serialVersionUID = -6457722746147666860L;
40  
41      @Basic
42      private String objectID;
43  
44      @Basic
45      @Column(name = "objectType", length = 128)
46      private String type;
47  
48      public MCRCategLinkReference() {
49      }
50  
51      public MCRCategLinkReference(MCRObjectID objectID) {
52          this(objectID.toString(), objectID.getTypeId());
53      }
54  
55      public MCRCategLinkReference(String objectID, String type) {
56          setObjectID(objectID);
57          setType(type);
58      }
59  
60      public MCRCategLinkReference(MCRPath path) {
61          this('/' + path.subpathComplete().toString(), path.getOwner());
62      }
63  
64      public String getObjectID() {
65          return objectID;
66      }
67  
68      public void setObjectID(String objectID) {
69          this.objectID = objectID;
70      }
71  
72      public String getType() {
73          return type;
74      }
75  
76      public void setType(String type) {
77          this.type = type;
78      }
79  
80      @Override
81      public int hashCode() {
82          final int prime = 31;
83          int result = 1;
84          result = prime * result + (objectID == null ? 0 : objectID.hashCode());
85          result = prime * result + (type == null ? 0 : type.hashCode());
86          return result;
87      }
88  
89      @Override
90      public boolean equals(Object obj) {
91          if (this == obj) {
92              return true;
93          }
94          if (obj == null) {
95              return false;
96          }
97          if (getClass() != obj.getClass()) {
98              return false;
99          }
100         final MCRCategLinkReference other = (MCRCategLinkReference) obj;
101         if (objectID == null) {
102             if (other.objectID != null) {
103                 return false;
104             }
105         } else if (!objectID.equals(other.objectID)) {
106             return false;
107         }
108         if (type == null) {
109             return other.type == null;
110         } else {
111             return type.equals(other.type);
112         }
113     }
114 
115     @Override
116     public String toString() {
117         return "MCRCategLinkReference [objectID=" + objectID + ", type=" + type + "]";
118     }
119 
120 }