Project

General

Profile

Download (1.62 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
import eu.etaxonomy.cdm.ref.TypedEntityReference;
15

    
16
/**
17
 * TODO replace by {@link TypedEntityReference} ?
18
 * @author cmathew
19
 * @since 24 Jun 2015
20
 */
21
public class CdmEntityIdentifier implements Serializable {
22

    
23
    private static final long serialVersionUID = 1479948194282284147L;
24

    
25
    private final int id;
26
    private final Class<? extends CdmBase> cdmClass;
27

    
28
    public CdmEntityIdentifier(int id, Class<? extends CdmBase> cdmClass) {
29
        this.id = id;
30
        this.cdmClass = cdmClass;
31
    }
32

    
33
    public int getId() {
34
        return id;
35
    }
36

    
37
    public Class getCdmClass() {
38
        return cdmClass;
39
    }
40

    
41
    @Override
42
    public boolean equals(Object obj) {
43
        if(obj == null || !(obj instanceof CdmEntityIdentifier)) {
44
            return false;
45
        }
46

    
47
        if(this == obj) {
48
            return true;
49
        }
50
        CdmEntityIdentifier that = (CdmEntityIdentifier) obj;
51
        if(this.cdmClass.equals(that.cdmClass) && this.id == that.id) {
52
            return true;
53
        }
54

    
55
        return false;
56
    }
57

    
58
    @Override
59
    public int hashCode() {
60
        return (this.cdmClass.getName() + String.valueOf(this.id)).hashCode();
61
    }
62

    
63
    @Override
64
    public String toString() {
65
        return this.cdmClass.getName() + String.valueOf(this.id);
66
    }
67
}
(1-1/36)