aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java
blob: 4f35b47219a63a84dbdce233822130cd81e529e5 (plain) (blame)
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
package com.yahoo.vespa.hosted.controller.api.integration.billing;

/**
 * @author gjoranv
 */
public enum BillStatus {
    OPEN,       // All bills start in this state. The bill can be modified and exported/synced to external systems.
    FROZEN,     // Syncing to external systems is switched off. No changes can be made.
    CLOSED,     // End state for a valid bill.
    VOID;       // End state, indicating that the bill is not valid.

    // Legacy states, used by historical bills
    private static final String LEGACY_ISSUED = "ISSUED";
    private static final String LEGACY_EXPORTED = "EXPORTED";
    private static final String LEGACY_CANCELED = "CANCELED";

    private final String value;

    BillStatus() {
        this.value = name();
    }

    public String value() {
        return value;
    }

    public static BillStatus from(String status) {
        if (LEGACY_ISSUED.equals(status) || LEGACY_EXPORTED.equals(status)) return OPEN;
        if (LEGACY_CANCELED.equals(status)) return VOID;
        return Enum.valueOf(BillStatus.class, status.toUpperCase());
    }

}