package de.ivu.elect.business.wahl.entity;

import java.net.MalformedURLException;
import java.net.URL;

import org.apache.commons.lang3.StringUtils;

public enum WesUebertragungsweg {

  USB_STICK {
    @Override
    public String validate(String wasUrl) {
      return null; // nichts zu tun
    }

    @Override
    public boolean isOnline() {
      return false;
    }

    @Override
    public boolean isUsbBackup() {
      return true;
    }

    @Override
    public boolean isHddBackup() {
      return true;
    }

    @Override
    public boolean isErfassungOhneTeamMoeglich() {
      return true;
    }
  },
  ONLINE {
    @Override
    public String validate(String wasUrl) {
      if (StringUtils.isBlank(wasUrl)) {
        return "wes.uebertragungsweg.online.url.fehlt";
      }

      try {
        new URL(wasUrl);
      } catch (MalformedURLException e) {
        return "wes.uebertragungsweg.online.url.ungueltig";
      }
      return null;
    }

    @Override
    public boolean isOnline() {
      return true;
    }

    @Override
    public boolean isUsbBackup() {
      return true;
    }

    @Override
    public boolean isHddBackup() {
      return true;
    }

    @Override
    public boolean isErfassungOhneTeamMoeglich() {
      return false;
    }
  },
  ONLINE_OHNE_USB_BACKUP {
    @Override
    public String validate(String wasUrl) {
      return ONLINE.validate(wasUrl);
    }

    @Override
    public boolean isOnline() {
      return true;
    }

    @Override
    public boolean isUsbBackup() {
      return false;
    }

    @Override
    public boolean isHddBackup() {
      return true;
    }

    @Override
    public boolean isErfassungOhneTeamMoeglich() {
      return false;
    }

  };

  public abstract String validate(String wasUrl);

  public abstract boolean isOnline() ;

  public abstract boolean isUsbBackup();

  public abstract boolean isHddBackup();

  public abstract boolean isErfassungOhneTeamMoeglich();


}
