xuxiuxi
2017-07-24 61a09a058a4963aa203ae2ef4f67477370a35ca2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cn.com.basic.face.service.sync.up;
 
public abstract class BaseSync {
 
    private BaseSync next;
    public boolean syncComplete = false;
 
    public boolean getSyncComplete() {
        return syncComplete;
    }
 
    public void setNext(BaseSync next) {
        this.next = next;
    }
 
    public void sync() {
        if (hasMore()) {
            syncComplete = false;
            doSync();
        } else {
            syncComplete = true;
            if (next != null) {
                next.sync();
            }
        }
    }
 
    public abstract void doSync();
 
    public abstract boolean hasMore();
 
    public void setComplete(boolean syncComplete) {
        this.syncComplete = syncComplete;
        if (next != null) {
            next.setComplete(syncComplete);
        }
    }
 
    public boolean lastUpSyncComplete() {
        BaseSync last = this;
        while (last.next != null) {
            last = last.next;
        }
        return last.getSyncComplete();
    }
 
}