Update README.md
This commit is contained in:
34
README.md
34
README.md
@@ -132,25 +132,15 @@ public class NameAndAgeBuilder {
|
||||
* Return a "with"er for an existing record instance
|
||||
*/
|
||||
public static NameAndAgeBuilder.With from(NameAndAge from) {
|
||||
return new NameAndAgeBuilder.With() {
|
||||
@Override
|
||||
public String name() {
|
||||
return from.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int age() {
|
||||
return from.age();
|
||||
}
|
||||
};
|
||||
return new _FromWith(from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a stream of the record components as map entries keyed with the component name and the value as the component value
|
||||
*/
|
||||
public static Stream<Map.Entry<String, Object>> stream(NameAndAge record) {
|
||||
return Stream.of(Map.entry("name", record.name()),
|
||||
Map.entry("age", record.age()));
|
||||
return Stream.of(new AbstractMap.SimpleImmutableEntry<>("name", record.name()),
|
||||
new AbstractMap.SimpleImmutableEntry<>("age", record.age()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,6 +241,24 @@ public class NameAndAgeBuilder {
|
||||
return new NameAndAge(name(), age);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class _FromWith implements NameAndAgeBuilder.With {
|
||||
private final NameAndAge from;
|
||||
|
||||
private _FromWith(NameAndAge from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return from.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int age() {
|
||||
return from.age();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user