package com.social.media.domain.campaign.valueobject;

/**
 * Campaign Status Enumeration
 * Represents the different states of a campaign lifecycle
 */
public enum CampaignStatus {
    DRAFT("Campaign is in draft state, not yet activated"),
    ACTIVE("Campaign is currently running"),
    PAUSED("Campaign is temporarily paused"),
    COMPLETED("Campaign has been completed successfully"),
    CANCELLED("Campaign has been cancelled"),
    FAILED("Campaign has failed due to errors");
    
    private final String description;
    
    CampaignStatus(String description) {
        this.description = description;
    }
    
    public String getDescription() {
        return description;
    }
    
    public boolean isActive() {
        return this == ACTIVE;
    }
    
    public boolean isFinished() {
        return this == COMPLETED || this == CANCELLED || this == FAILED;
    }
    
    public boolean canBeModified() {
        return this == DRAFT || this == PAUSED;
    }
    
    public boolean canTransitionTo(CampaignStatus newStatus) {
        return switch (this) {
            case DRAFT -> newStatus == ACTIVE || newStatus == CANCELLED;
            case ACTIVE -> newStatus == PAUSED || newStatus == COMPLETED || newStatus == CANCELLED || newStatus == FAILED;
            case PAUSED -> newStatus == ACTIVE || newStatus == CANCELLED;
            case COMPLETED, CANCELLED, FAILED -> false; // Terminal states
        };
    }
}
