BagStatus.kt 1.06 KB
Newer Older
1
package org.chronopolis.rest.models.enums
Michael Ritter's avatar
Michael Ritter committed
2

3 4 5 6 7 8 9 10
import com.google.common.collect.ImmutableListMultimap
import com.google.common.collect.ImmutableSet

/**
 * Status types for Bags
 *
 * @author shake
 */
Michael Ritter's avatar
Michael Ritter committed
11 12 13 14 15 16 17 18 19 20 21
enum class BagStatus {
    DEPOSITED,
    INITIALIZED,
    TOKENIZED,
    REPLICATING,
    PRESERVED,
    DEPRECATED,
    DELETED,
    ERROR;

    companion object {
22 23 24 25 26
        fun processingStates(): Set<BagStatus> =
                ImmutableSet.of(DEPOSITED, INITIALIZED, TOKENIZED, REPLICATING)

        fun preservedStates(): Set<BagStatus> = ImmutableSet.of(PRESERVED)

Michael Ritter's avatar
Michael Ritter committed
27
        @Suppress("MemberVisibilityCanBePrivate")
28 29 30 31 32 33 34 35
        fun inactiveStates(): Set<BagStatus> = ImmutableSet.of(DEPRECATED, DELETED, ERROR)

        fun statusByGroup(): ImmutableListMultimap<String, BagStatus> =
                ImmutableListMultimap.Builder<String, BagStatus>()
                        .putAll("Processing", processingStates())
                        .putAll("Preserved", preservedStates())
                        .putAll("Inactive", inactiveStates())
                        .build()
Michael Ritter's avatar
Michael Ritter committed
36 37
    }
}