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
|
* Return a "with"er for an existing record instance
|
||||||
*/
|
*/
|
||||||
public static NameAndAgeBuilder.With from(NameAndAge from) {
|
public static NameAndAgeBuilder.With from(NameAndAge from) {
|
||||||
return new NameAndAgeBuilder.With() {
|
return new _FromWith(from);
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return from.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int age() {
|
|
||||||
return from.age();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a stream of the record components as map entries keyed with the component name and the value as the component value
|
* 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) {
|
public static Stream<Map.Entry<String, Object>> stream(NameAndAge record) {
|
||||||
return Stream.of(Map.entry("name", record.name()),
|
return Stream.of(new AbstractMap.SimpleImmutableEntry<>("name", record.name()),
|
||||||
Map.entry("age", record.age()));
|
new AbstractMap.SimpleImmutableEntry<>("age", record.age()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -251,6 +241,24 @@ public class NameAndAgeBuilder {
|
|||||||
return new NameAndAge(name(), age);
|
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