1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.api.application;
|
11
|
|
12
|
import java.util.Set;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
15
|
|
16
|
/**
|
17
|
* @author cmathew
|
18
|
* @date 7 Apr 2015
|
19
|
*
|
20
|
*/
|
21
|
public class CdmChangeEvent {
|
22
|
|
23
|
public enum Action {
|
24
|
Create,
|
25
|
Update,
|
26
|
Delete
|
27
|
}
|
28
|
|
29
|
private final Action action;
|
30
|
private final Set<? extends CdmBase> changedObjects;
|
31
|
private final Class sourceType;
|
32
|
private Object source;
|
33
|
|
34
|
public CdmChangeEvent(Action action, Set<? extends CdmBase> changedObjects, Class sourceType) {
|
35
|
this.action = action;
|
36
|
this.changedObjects = changedObjects;
|
37
|
this.sourceType = sourceType;
|
38
|
}
|
39
|
|
40
|
public CdmChangeEvent(Action action, Set<? extends CdmBase> changedObjects, Object source) {
|
41
|
this(action, changedObjects, source.getClass());
|
42
|
this.source = source;
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* @return the action
|
47
|
*/
|
48
|
public Action getAction() {
|
49
|
return action;
|
50
|
}
|
51
|
|
52
|
/**
|
53
|
* @return the changedObjects
|
54
|
*/
|
55
|
public Set<? extends CdmBase> getChangedObjects() {
|
56
|
return changedObjects;
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* @return the sourceType
|
61
|
*/
|
62
|
public Class getSourceType() {
|
63
|
return sourceType;
|
64
|
}
|
65
|
|
66
|
|
67
|
/**
|
68
|
* @return the source
|
69
|
*/
|
70
|
public Object getSource() {
|
71
|
return source;
|
72
|
}
|
73
|
|
74
|
public boolean hasChanges() {
|
75
|
return changedObjects != null && !changedObjects.isEmpty();
|
76
|
}
|
77
|
|
78
|
}
|