Subversion Repositories SmartDukaan

Rev

Rev 37935 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37935 Rev 37946
Line 3... Line 3...
3
import java.util.Collections;
3
import java.util.Collections;
4
import java.util.EnumSet;
4
import java.util.EnumSet;
5
import java.util.Set;
5
import java.util.Set;
6
 
6
 
7
/**
7
/**
8
 * Lifecycle of a partner store, the single source of truth for fofo_store.active / closed.
8
 * Lifecycle of a partner store (fofo_store.store_status), the single source of truth for its state.
9
 * ACTIVE and PAUSED can log in; PAUSED cannot spend from the wallet. SUSPENDED (nearing closure) and CLOSED cannot
9
 * ACTIVE and PAUSED can log in; PAUSED cannot spend from the wallet. SUSPENDED (nearing closure) and CLOSED cannot
10
 * log in. CLOSED is permanent: revival of a closed partner creates a new store.
10
 * log in. CLOSED is permanent: revival of a closed partner creates a new store.
11
 */
11
 */
12
public enum StoreStatus {
12
public enum StoreStatus {
13
	ACTIVE(true, true),
13
	ACTIVE(true, true),
Line 48... Line 48...
48
 
48
 
49
	public boolean canMoveTo(StoreStatus target) {
49
	public boolean canMoveTo(StoreStatus target) {
50
		return nextStatuses().contains(target);
50
		return nextStatuses().contains(target);
51
	}
51
	}
52
 
52
 
53
	public static StoreStatus fromFlags(boolean active, boolean closed) {
-
 
54
		return closed ? CLOSED : active ? ACTIVE : SUSPENDED;
-
 
55
	}
-
 
56
 
-
 
57
	public static Set<StoreStatus> loginStatuses() {
53
	public static Set<StoreStatus> loginStatuses() {
58
		return Collections.unmodifiableSet(EnumSet.of(ACTIVE, PAUSED));
54
		return Collections.unmodifiableSet(EnumSet.of(ACTIVE, PAUSED));
59
	}
55
	}
60
}
56
}