Why not build a string yourself? The code is simple to write and understand, without using any specific features of Java 8.
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()).append('{') sb.append("userId=").append(userId); sb.append(", timestamp=").append(timestamp); return sb.append('}').toString(); }
source share