Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class Employee {
- public static void main(String[] args) {
- // Employee e = new Employee("Lex", 24, 250);
- // e = Employee.setName(e, "Vasili");
- // e = Employee.setAge(e, 12);
- // e = Employee.setSalary(e, 2500);
- // Employee.log(e);
- Stream
- .of(new Employee())
- .map((e, "Vasili") -> Employee::setName)
- .findFirst()
- .get();
- }
- public final String name;
- public final Integer age;
- public final Integer salary;
- public Employee(final String nameArg,
- final Integer ageArg,
- final Integer salaryArg) {
- this.name = nameArg;
- this.age = ageArg;
- this.salary = salaryArg;
- }
- public static Employee setName(final Employee e, final String n) {
- return new Employee(n, e.age, e.salary);
- }
- public static Employee setAge(final Employee e, final Integer a) {
- return new Employee(e.name, a, e.salary);
- }
- public static Employee setSalary(final Employee e, final Integer s) {
- return new Employee(e.name, e.age, s);
- }
- public static void log(final Employee e) {
- System.out.println("Name: " + e.name + ", " +
- "age: " + e.age + ", " +
- "salary: " + e.salary + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment