package uk.co.benjiweber.expressions;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public interface ToString<T> {
    default String autoToString() {
        return "{" +
        props().stream()
            .map(prop -> (Object)prop.apply((T)this))
            .filter(prop -> prop != null)
            .map(Object::toString)
            .collect(Collectors.joining(", ")) +
        "}";
    }

    List<Function<T,?>> props();

}

@@ -312,14 +312,11 @@
    .
-filter
+map
 (pro
@@ -329,50 +329,37 @@
 rop 
-!
+=
 = null
-)%0A            .map(Object::
+ ? %22_%22 : prop.
 toString
 )%0A  
@@ -354,16 +354,18 @@
 toString
+()
 )%0A      

Print nulls as underscores in default ToString.