vendredi 7 août 2020

How to retrieve the function of java.util.function.Consumer instance?

How can I reparse java.util.function.Consumer instance and print its function parameters and values (forexample student.person.surname) or print the consumer function of which content is "s.getPerson().setSurName()" as a text.

import lombok.Data;

import java.util.function.Consumer;

public class ConsumerTest {

    @Data
    public static class Person{
        private Integer id;
        private String name;
        private String surName;
    }

    @Data
    public static class Student{
        private Integer id;
        private Person person;
    }

    public static void main(String args[])
    {
        Student student = new Student();
        student.setId(1);
        Person person = new Person();
        person.setName("Ali");
        person.setSurName("Veli");
        person.setId(2);
        student.setPerson(person);

        Consumer<Student> displayLambda = s -> s.getPerson().setSurName("Gülsoy");

    //At here I want to reparse displaylambda instance and print parameters student.person.surname ve value.          
    // or I want to print the function of which content is "s.getPerson().setSurName("Gülsoy")" as text.

        displayLambda.accept(student);
    }

}




Aucun commentaire:

Enregistrer un commentaire