package org.hummingbirdlang.types.composite;

import org.hummingbirdlang.types.CompositeType;
import org.hummingbirdlang.types.Property;
import org.hummingbirdlang.types.PropertyNotFoundException;
import org.hummingbirdlang.types.Type;

/**
 * Disjoint union type (aka. sum type): it is composed of members A and B.
 * Eventually the union is discriminated into either A or B.
 */
public class SumType extends CompositeType {
  public final Type[] subTypes;

  public SumType(Type[] subTypes) {
    this.subTypes = subTypes;
  }

  @Override
  public Property getProperty(String name) throws PropertyNotFoundException {
    throw new PropertyNotFoundException("Not yet implemented");
  }
}

@@ -680,11 +680,338 @@
 d%22);%0A  %7D
+%0A%0A  @Override%0A  public String toString() %7B%0A    StringBuilder result = new StringBuilder();%0A    boolean bar = false;%0A    for (Type subType : this.subTypes) %7B%0A      if (bar) %7B%0A        result.append(%22 %7C %22);%0A      %7D else %7B%0A        bar = true;%0A      %7D%0A      result.append(subType.toString());%0A    %7D%0A    return result.toString();%0A  %7D
 %0A%7D%0A

Improve debug `toString` for sum type