1
|
/**
|
2
|
* Copyright (C) 2017 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.vaadin.event;
|
10
|
|
11
|
import java.util.EnumSet;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14
|
import eu.etaxonomy.vaadin.mvp.AbstractView;
|
15
|
|
16
|
/**
|
17
|
* @author a.kohlbecker
|
18
|
* @since May 10, 2017
|
19
|
*
|
20
|
*/
|
21
|
public class EntityChangeEvent<T extends CdmBase> extends AbstractEntityEvent<EntityChangeEvent.Type> {
|
22
|
|
23
|
public enum Type {
|
24
|
CREATED,
|
25
|
MODIFIED,
|
26
|
REMOVED;
|
27
|
}
|
28
|
|
29
|
public static final EnumSet<Type> CREATE_OR_MODIFIED = EnumSet.of(EntityChangeEvent.Type.CREATED, EntityChangeEvent.Type.MODIFIED);
|
30
|
|
31
|
private Class<T> entityType;
|
32
|
|
33
|
private T entity;
|
34
|
|
35
|
public EntityChangeEvent(T entity, Type type, AbstractView sourceView) {
|
36
|
super(type, entity.getUuid(), sourceView);
|
37
|
this.entityType = (Class<T>) entity.getClass();
|
38
|
this.entity = entity;
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* @return the entityType
|
43
|
*/
|
44
|
public Class<?> getEntityType() {
|
45
|
return entityType;
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* @return the entity
|
50
|
*/
|
51
|
public T getEntity() {
|
52
|
return entity;
|
53
|
}
|
54
|
|
55
|
public boolean isCreateOrModifiedType() {
|
56
|
return CREATE_OR_MODIFIED.contains(type);
|
57
|
}
|
58
|
|
59
|
public boolean isRemovedType() {
|
60
|
return Type.REMOVED.equals(type);
|
61
|
}
|
62
|
|
63
|
}
|