public BooleanWrapper[] isComplete() {
   ArrayList<BooleanWrapper> incomplete = new ArrayList<BooleanWrapper>();
   for (FormalDefinitionComponent comp : this.getComponents()) {
     BooleanWrapper amComplete = comp.isComplete();
     if (amComplete.isError()) incomplete.add(amComplete);
   }
   return incomplete.toArray(new BooleanWrapper[0]);
 }
 public FormalDefinition(FormalDefinitionComponent... comps) {
   myComponents = new LinkedList<FormalDefinitionComponent>();
   for (FormalDefinitionComponent comp : comps) {
     myComponents.add(comp);
     comp.addListener(this);
   }
   for (Alphabet a : this.getAlphabets()) a.addRules(new DisallowedCharacterRule(this));
   updateAlphabets(ITEM_MODIFIED);
 }
  @Override
  public String toString() {
    String out = this.toNtupleString() + "\n";

    for (FormalDefinitionComponent comp : this.getComponents()) {
      out += "\t" + comp.toString() + "\n";
    }

    return out;
  }
  public String toNtupleString() {
    String out = this.getDescriptionName() + " = (";

    for (FormalDefinitionComponent comp : this.getComponents()) {
      out += comp.getCharacterAbbr() + ", ";
    }

    out = out.substring(0, out.length() - 2) + ")";

    return out;
  }
  public void componentChanged(AdvancedChangeEvent event) {
    for (FormalDefinitionComponent comp : this.getComponents()) {
      if (!event.comesFrom(comp.getClass())) continue;

      if (comp instanceof Alphabet) {
        switch (event.getType()) {
          case ITEM_REMOVED:
            this.purgeOfSymbols((Alphabet) comp, (Collection<Symbol>) event.getArg(0));
            return;
          case ITEM_MODIFIED:
            Symbol from = (Symbol) event.getArg(0);
            Symbol to = (Symbol) event.getArg(1);
            applySymbolMod(from.getString(), to.getString());
        }
      }

      if (comp instanceof UsesSymbols) {
        updateAlphabets(event.getType());
        return;
      }
    }
  }
 public <T extends FormalDefinitionComponent> T getComponentOfClass(Class<T> clz) {
   for (FormalDefinitionComponent comp : this.getComponents()) {
     if (clz.isAssignableFrom(comp.getClass())) return clz.cast(comp);
   }
   return null;
 }