Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / searchPostProcess / distinctOn / FirstAggregateOperation.java @ 45705

History | View | Annotate | Download (1.33 KB)

1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.swing.impl.searchPostProcess.distinctOn;
7

    
8
/**
9
 *
10
 * @author jovivas
11
 */
12
public class FirstAggregateOperation implements AggregateOperation {
13
    public static class FirstAggregateOperationFactory implements AggregateOperationFactory{
14

    
15
        @Override
16
        public String getName() {
17
            return "First value";
18
        }
19

    
20
        @Override
21
        public AggregateOperation create(Object... os) {
22
            return new FirstAggregateOperation();
23
        }
24

    
25
        @Override
26
        public boolean isApplicable(Object... value) {
27
            return true;
28
        }
29
    }
30
    
31
    Object first;
32
    boolean isFirst = true;
33

    
34
    public FirstAggregateOperation() {
35
        this.first = null;
36
    }
37

    
38
    @Override
39
    public boolean isApplicable(Object... value) {
40
        return true;
41
    }
42

    
43
    @Override
44
    public void reset() {
45
        this.first = null;
46
        this.isFirst=true;
47
    }
48

    
49
    @Override
50
    public void perform(Object value) {    
51
        if (isFirst) {
52
            this.first = value;
53
            isFirst = false;
54
        }
55
    }
56

    
57
    @Override
58
    public Object getValue() {
59
        return this.first;
60
    }
61
    
62
}