Project

General

Profile

Download (1.54 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service.dto;
10

    
11
import java.io.Serializable;
12

    
13
import eu.etaxonomy.cdm.model.common.CdmBase;
14

    
15
/**
16
 * @author cmathew
17
 \* @since 24 Jun 2015
18
 *
19
 */
20
public class CdmEntityIdentifier implements Serializable {
21

    
22

    
23
    /**
24
     *
25
     */
26
    private static final long serialVersionUID = 1479948194282284147L;
27

    
28

    
29
    private final int id;
30
    private final Class<? extends CdmBase> cdmClass;
31

    
32
    public CdmEntityIdentifier(int id, Class cdmClass) {
33
        this.id = id;
34
        this.cdmClass = cdmClass;
35
    }
36

    
37

    
38
    public int getId() {
39
        return id;
40
    }
41

    
42
    public Class getCdmClass() {
43
        return cdmClass;
44
    }
45

    
46
    @Override
47
    public boolean equals(Object obj) {
48
        if(obj == null || !(obj instanceof CdmEntityIdentifier)) {
49
            return false;
50
        }
51

    
52
        if(this == obj) {
53
            return true;
54
        }
55
        CdmEntityIdentifier that = (CdmEntityIdentifier) obj;
56
        if(this.cdmClass.equals(that.cdmClass) && this.id == that.id) {
57
            return true;
58
        }
59

    
60
        return false;
61
    }
62

    
63
    @Override
64
    public int hashCode() {
65
        return (this.cdmClass.getName() + String.valueOf(this.id)).hashCode();
66
    }
67

    
68
    @Override
69
    public String toString() {
70
        return this.cdmClass.getName() + String.valueOf(this.id);
71
    }
72
}
(1-1/20)