package yokohama.unit.ast_junit;

import java.util.List;
import java.util.Set;
import lombok.EqualsAndHashCode;
import lombok.Value;
import yokohama.unit.util.SBuilder;
import static yokohama.unit.util.SetUtils.setOf;

@Value
@EqualsAndHashCode(callSuper=false)
public class SuchThatMatcherExpr extends MatcherExpr {
    private List<Statement> statements;

    @Override
    public void getExpr(SBuilder sb, String varName, ExpressionStrategy expressionStrategy, MockStrategy mockStrategy) {
        sb.appendln("Matcher ", varName, " = new BaseMatcher() {");
        sb.shift();
            sb.appendln("@Override");
            sb.appendln("public boolean matches(Object obj) {");
            sb.shift();
            for (Statement statement : statements) {
                statement.toString(sb, expressionStrategy, mockStrategy);
            }
            sb.unshift();
            sb.appendln("}");
        sb.unshift();
        sb.appendln("};");
    }

    @Override
    public Set<ImportedName> importedNames() {
        return setOf(new ImportClass("org.hamcrest.BaseMatcher"));
    }
}

@@ -920,24 +920,173 @@
 ndln(%22%7D%22);%0D%0A
+            sb.appendln(%22@Override%22);%0D%0A            sb.appendln(%22public void describeTo(Description description) %7B%22);%0D%0A            sb.appendln(%22%7D%22);%0D%0A
         sb.u
@@ -1217,16 +1217,34 @@
 n setOf(
+%0D%0A                
 new Impo
@@ -1278,16 +1278,78 @@
 atcher%22)
+,%0D%0A                new ImportClass(%22org.hamcrest.Description%22)
 );%0D%0A    

Add (empty) decribeTo method to generated code