Project

General

Profile

Download (2.14 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.vaadin.session;
10

    
11
import java.util.List;
12

    
13
import com.vaadin.ui.Component;
14

    
15
/**
16
 * @author cmathew
17
 * @date 7 Apr 2015
18
 *
19
 */
20
public class CdmChangeEvent {
21

    
22
    public enum Action {
23
        Create,
24
        Update,
25
        Delete
26
    }
27

    
28
    private final Action action;
29
    private final List<Object> changedObjects;
30
    private Class<? extends Component> sourceType;
31
    private Object source;
32

    
33
    public CdmChangeEvent(Action action, List<Object> changedObjects, Class<? extends Component> sourceType) {
34
        this.action = action;
35
        this.changedObjects = changedObjects;
36
        if(changedObjects == null || changedObjects.isEmpty()) {
37
            throw new IllegalArgumentException("Changed objects cannot be empty");
38
        }
39
        this.sourceType = sourceType;
40
        if(sourceType == null) {
41
            throw new IllegalArgumentException("Source type cannot be null");
42
        }
43
    }
44

    
45
    public CdmChangeEvent(Action action, List<Object> changedObjects, Component source) {
46
        this.action = action;
47
        this.changedObjects = changedObjects;
48
        if(changedObjects == null || changedObjects.isEmpty()) {
49
            throw new IllegalArgumentException("Changed objects cannot be empty");
50
        }
51
        this.source= source;
52
        if(source == null) {
53
            throw new IllegalArgumentException("Source cannot be null");
54
        }
55
        this.sourceType = source.getClass();
56
    }
57

    
58
    /**
59
     * @return the action
60
     */
61
    public Action getAction() {
62
        return action;
63
    }
64

    
65
    /**
66
     * @return the changedObjects
67
     */
68
    public List<Object> getChangedObjects() {
69
        return changedObjects;
70
    }
71

    
72
    /**
73
     * @return the sourceType
74
     */
75
    public Class<? extends Component> getSourceType() {
76
        return sourceType;
77
    }
78

    
79

    
80
    /**
81
     * @return the source
82
     */
83
    public Object getSource() {
84
        return source;
85
    }
86

    
87
}
(3-3/9)