xuxiuxi
2017-08-01 21e08324c323d0c5d1e7cedc36323c554857a239
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
48
49
50
51
52
53
54
55
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() {
        //System.out.println("sync."+this.getClass().getName()+" 正在向上同步");
        if (hasMore()) {
            syncComplete = false;
            doSync();
        } else {
            syncComplete = true;
            if (next != null) {
                next.sync();
            }
        }
    }
 
    public abstract void doSync();
 
    public abstract boolean hasMore();
 
    public void setSyncComplete(boolean syncComplete) {
        this.syncComplete = syncComplete;
    }
 
    public void setAllSyncComplete(boolean syncComplete) {
        this.syncComplete = syncComplete;
        if (next != null) {
            next.setSyncComplete(syncComplete);
        }
    }
 
    public boolean lastUpSyncComplete() {
        BaseSync last = this;
        while (last.next != null) {
            last = last.next;
        }
        return last.getSyncComplete();
    }
 
    public BaseSync getNext() {
        return next;
    }
}