All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hydra.langs.java.syntax.SwitchLabel Maven / Gradle / Ivy

package hydra.langs.java.syntax;

import java.io.Serializable;

public abstract class SwitchLabel implements Serializable {
  public static final hydra.core.Name NAME = new hydra.core.Name("hydra/langs/java/syntax.SwitchLabel");
  
  private SwitchLabel () {
  
  }
  
  public abstract  R accept(Visitor visitor) ;
  
  public interface Visitor {
    R visit(Constant instance) ;
    
    R visit(EnumConstant instance) ;
    
    R visit(Default instance) ;
  }
  
  public interface PartialVisitor extends Visitor {
    default R otherwise(SwitchLabel instance) {
      throw new IllegalStateException("Non-exhaustive patterns when matching: " + (instance));
    }
    
    default R visit(Constant instance) {
      return otherwise((instance));
    }
    
    default R visit(EnumConstant instance) {
      return otherwise((instance));
    }
    
    default R visit(Default instance) {
      return otherwise((instance));
    }
  }
  
  public static final class Constant extends hydra.langs.java.syntax.SwitchLabel implements Serializable {
    public final hydra.langs.java.syntax.ConstantExpression value;
    
    public Constant (hydra.langs.java.syntax.ConstantExpression value) {
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Constant)) {
        return false;
      }
      Constant o = (Constant) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
  
  public static final class EnumConstant extends hydra.langs.java.syntax.SwitchLabel implements Serializable {
    public final hydra.langs.java.syntax.EnumConstantName value;
    
    public EnumConstant (hydra.langs.java.syntax.EnumConstantName value) {
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof EnumConstant)) {
        return false;
      }
      EnumConstant o = (EnumConstant) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
  
  public static final class Default extends hydra.langs.java.syntax.SwitchLabel implements Serializable {
    public Default () {
    
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Default)) {
        return false;
      }
      Default o = (Default) (other);
      return true;
    }
    
    @Override
    public int hashCode() {
      return 0;
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy