class Decorator<T> extends TypedVisitor<T> implements Comparable<Decorator> {

  public Class<? extends Decorator>[] after() {
    return new Class[0];
  }

  public Class<? extends Decorator>[] before() {
    return new Class[0];
  }

  @Override
  public int compareTo(Decorator o) {<FILL_FUNCTION_BODY>}
}

    //We only want to return 0 if decorators are equal.
    if (this.equals(o)) {
      return 0;
    }
    Class c = o.getClass();
    //1st pass: ours
    for (Class b : before()) {
      if (b.isAssignableFrom(c)) {
        return -1;
      }
    }
    for (Class a : after()) {
      if (a.isAssignableFrom(c)) {
        return 1;
      }
    }
    //2nd pass: their
    for (Class b : o.before()) {
      if (b.isAssignableFrom(getClass())) {
        return 1;
      }
    }
    for (Class a : o.after()) {
      if (a.isAssignableFrom(getClass())) {
        return -1;
      }
    }
    //Reproducible order every single time
    int result = getClass().getName().compareTo(o.getClass().getName());
    if (result == 0) {
      result = hashCode() - o.hashCode();
    }
    return result;
  
<no_super_class>