Project

General

Profile

1
package eu.dnetlib.data.mapreduce.util;
2

    
3
import eu.dnetlib.data.proto.RelTypeProtos.RelType;
4
import eu.dnetlib.data.proto.RelTypeProtos.SubRelType;
5

    
6
public class RelDescriptor {
7

    
8
	public static final String SEPARATOR = "_";
9

    
10
	private final String it;
11

    
12
	// relType also corresponds to the Ontology code
13
	private final RelType relType;
14

    
15
	private final SubRelType subRelType;
16

    
17
	private final String relClass;
18

    
19

    
20
	// <TERM code="hasAmongTopNSimilarDocuments" encoding="resultResult_similarity_hasAmongTopNSimilarDocuments"
21
	//final String rd = oafRel.getRelType().toString() + "_" + oafRel.getSubRelType() + "_" + relClasses.getInverse(oafRel.getRelClass());
22
	//<ONTOLOGY_NAME code="dnet:result_result_relations">
23
	public RelDescriptor(final String value) {
24
		super();
25
		this.it = value;
26

    
27
		String[] s = value.split(SEPARATOR);
28

    
29
		this.relType = RelType.valueOf(s[0]);
30
		this.subRelType = SubRelType.valueOf(s[1]);
31
		this.relClass = s[2];
32

    
33
	}
34

    
35
	public SubRelType getSubRelType() {
36
		return subRelType;
37
	}
38

    
39
	public RelType getRelType() {
40
		return relType;
41
	}
42

    
43
	public String getRelClass() {
44
		return relClass;
45
	}
46

    
47
	public String getIt() {
48
		return it;
49
	}
50

    
51

    
52
	@Override
53
	public String toString() {
54
		return getIt();
55
	}
56

    
57
	@Override
58
	public int hashCode() {
59
		final int prime = 31;
60
		int result = 1;
61
		result = (prime * result) + ((it == null) ? 0 : it.hashCode());
62
		return result;
63
	}
64

    
65
	@Override
66
	public boolean equals(final Object obj) {
67
		if (this == obj) return true;
68
		if (obj == null) return false;
69
		if (getClass() != obj.getClass()) return false;
70
		RelDescriptor other = (RelDescriptor) obj;
71
		if (it == null) {
72
			if (other.it != null) return false;
73
		} else if (!it.equals(other.it)) return false;
74
		return true;
75
	}
76

    
77
}
(6-6/6)