package nl.jpoint.maven.vertx.utils.deploy.strategy;

import com.amazonaws.services.autoscaling.model.AutoScalingGroup;
import nl.jpoint.maven.vertx.mojo.DeployConfiguration;
import nl.jpoint.maven.vertx.utils.Ec2Instance;

import java.util.List;

public final class DeployStateStrategyFactory {

    private DeployStateStrategyFactory() {
        // Hide
    }

    public static boolean isDeployable(DeployConfiguration activeConfiguration, AutoScalingGroup autoScalingGroup, List<Ec2Instance> instances) {
        boolean canDeploy = false;
        // default calculatorF
        switch (activeConfiguration.getDeployStrategy()) {
            case KEEP_CAPACITY:
                canDeploy = new KeepCapacityStrategy().isDeployable(activeConfiguration, autoScalingGroup, instances);
                break;
            case DEFAULT:
                canDeploy = new DefaultDeployStrategy().isDeployable(activeConfiguration, autoScalingGroup, instances);
                break;
            case GUARANTEE_MINIMUM:
                canDeploy = new GuaranteeMinimumStrategy().isDeployable(activeConfiguration, autoScalingGroup, instances);
                break;
            case WHATEVER:
                canDeploy = new WhateverStrategy().isDeployable(activeConfiguration, autoScalingGroup, instances);
                break;
            case SPIN_AND_REMOVE:
                // default to false
                break;
            default:

        }
        return canDeploy;
    }

    public static boolean isDeployableOnError(DeployConfiguration activeConfiguration, AutoScalingGroup asGroup, List<Ec2Instance> instances) {
        return activeConfiguration.getDeployStrategy().ordinal() > 1 && isDeployable(activeConfiguration, asGroup, instances);

    }
}

@@ -541,39 +541,8 @@
 se;%0A
-        // default calculatorF%0A
     
@@ -1340,27 +1340,25 @@
     
-// default to false
+canDeploy = true;
 %0A   
@@ -1547,17 +1547,26 @@
 gGroup a
-s
+utoScaling
 Group, L
@@ -1607,72 +1607,354 @@
     
-return activeConfiguration.getDeployStrategy().ordinal() %3E 1 && 
+boolean canDeploy = false;%0A        switch (activeConfiguration.getDeployStrategy()) %7B%0A            case GUARANTEE_MINIMUM:%0A                canDeploy = new GuaranteeMinimumStrategy().isDeployable(activeConfiguration, autoScalingGroup, instances);%0A                break;%0A            case WHATEVER:%0A                canDeploy = new WhateverStrategy().
 isDe
@@ -1984,17 +1984,26 @@
 ation, a
-s
+utoScaling
 Group, i
@@ -2012,16 +2012,96 @@
 tances);
+%0A                break;%0A            default:%0A        %7D%0A        return canDeploy;
 %0A%0A    %7D%0A

fix calculation if asg is deployable