Rev 37935 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.enumuration.fofo;import java.util.Collections;import java.util.EnumSet;import java.util.Set;/*** Lifecycle of a partner store (fofo_store.store_status), the single source of truth for its state.* ACTIVE and PAUSED can log in; PAUSED cannot spend from the wallet. SUSPENDED (nearing closure) and CLOSED cannot* log in. CLOSED is permanent: revival of a closed partner creates a new store.*/public enum StoreStatus {ACTIVE(true, true),PAUSED(true, false),SUSPENDED(false, false),CLOSED(false, false);private final boolean login;private final boolean walletSpend;StoreStatus(boolean login, boolean walletSpend) {this.login = login;this.walletSpend = walletSpend;}/** Partner can log in, and the store counts as active everywhere active was used before. */public boolean canLogin() {return login;}/** Partner-initiated wallet debits are allowed. System, admin and cron debits ignore this. */public boolean canSpendWallet() {return walletSpend;}public Set<StoreStatus> nextStatuses() {switch (this) {case ACTIVE:return Collections.unmodifiableSet(EnumSet.of(PAUSED, SUSPENDED));case PAUSED:return Collections.unmodifiableSet(EnumSet.of(ACTIVE, SUSPENDED));case SUSPENDED:return Collections.unmodifiableSet(EnumSet.of(ACTIVE, PAUSED, CLOSED));default:return Collections.emptySet();}}public boolean canMoveTo(StoreStatus target) {return nextStatuses().contains(target);}public static Set<StoreStatus> loginStatuses() {return Collections.unmodifiableSet(EnumSet.of(ACTIVE, PAUSED));}}