Hi, welcome back in this lecture, we're going to be updating Playlist.
And in next lecture, we're underwriting your taste good taste update employee at his debut.
Let's head over to employee controller.
Will you and go to the bottom?
And let's go and let's build a bridge and place debut.
Well, let's ride the metro area public and the response type of the matter is this policy entity.
So this is a general class.
Let's pass employ as a type and then let's assume antonym as a great employee and let one expose the
parameters to this method.
First one is employed a bit long, second parameter employee object.
So this employee object is nothing but the updated employee object that basically Klein sends in the
request.
Now, let's senator, this matter it at what mapping undertaken to map a city would request.
Now, let's bus the ID for this annotation.
Let's I.D. So this is nothing but a party variable.
All right.
Now, in order to bind the value of this, you know, I.D. with the method argument that is employed,
we can use that part variable annotation.
Let's go.
Let's use part variable annotation where you and just pass the ID.
All right.
So basically at part, very well on rotation.
It will bind the value of this.
You want a template variable to the method argument that is employed.
OK.
And second argument look at here the employer object.
Now we want to bind Jason employee object in the request body.
Would this imply object?
So in order to do that, let's use adequate body annotation.
Well, this article is about in addition, basically map the request body with this, you know, Joe
object, and it internally uses as dated message converters to convert adjacent into Java object.
Perfect.
No, I do not do is when I have a written statement for you and then call employee service.
So first, we're going to get a ampleur object from the database by using this implied and then we'll
update that object with this new object.
OK, so in order to do that, let's call get employed by the method and pass the employee to it.
Well, look at you.
Get employed by limited returns.
Optional USB type employee and optional class provides a map method.
You can use a map method to perform different operation on the response of this method.
OK, let me show you how to do that.
Here, I'm going to call a mathematical map method into analytics function, and I interface that is
a function interface and when I was a alarmed expedition to implement this function interface.
So let's go ahead and choose Map Method and get them provided it does optional app type employee.
So we need to pass a simpler object here so we can project, let's say, self-employed in real time
project and get them globally.
Matter does your project from the database right?
So see, every employee is nothing but object, which you will get from database.
Now we want to update this every employee object by this object.
So this is the object that sent by the client.
Right?
And this object contains all the updated information like first name, last name and email.
Now let's go.
Let's update all the information from this object to see what object, and then we'll update this Sara
object into the database.
Well, here we need to provide the lambda expression, so we going to write the multiple statements
within this lambda expression.
So let's have a open include.
But we're here and let's go ahead and let's set first name.
From this imply object employee not get posed nude and similarly.
Let's do it for last name, email, etc. Last name employed did not get last name and then say what
employee or seal?
Email, said the email and an employee.
Not get email perfect.
No.
Why don't we do it when I do this silly employee object?
So in order to do that, let's call employee service.
It has update implemented and then person, said employee OK, because every employee contains all the
updated information, right?
Because we have updated first name, last name email from this employer, JÃ©rusalem.
I know we are going to sue or we are going to update this every employee object.
That's it.
And again, update employee basically matter returns the updated employee object.
So let's go ahead and let's get the response of this matter.
Let's see updated employees.
All right.
Perfect motive to return from here to new and then response entity and then pass here.
Updated employee as opposed to the second element entity status dot.
OK.
All right now we have completed map method implementation.
So this map method basically executes whenever we get employer I.D. method, it does a valid employee
object.
Right?
Let's say we get employed by elementary agency and plugged it with a given I.D. Then this map method
will be executed.
Otherwise, you'll be employees not used to take you inside.
Then what is the special return or status code?
Not phone to the client, right?
In order to do that, when you call another method here that is Oriels get method and again, or else
get method takes excess supplier as a function interface.
And we need to provide an explanation to implement this supplier function interface, right?
So go ahead and use this method, will you?
The next one is how lambda expiration were you?
And just call this business entity and then it has a method, not phone, and then just build this object.
That's it.
It's pretty simple, isn't it?
So what we have done, we have called that employer by the method, which returns optional type employee
and optional class provides a map method.
We can choose a map method to map one object to another object.
So here basically, we are mapping the third employee object with the employee object, and we are just
calling to employment that we're we're to just update this updated employee to the database and then
update employment returns for updated employee object and that updated employee object.
We are passing to the responsive entity with the status quo.
Okay.
Well, it's pretty simple.
We get the employee object by using a template by the method.
And if the employer object is not null, then we simply update that the employee object and we sell
to the database and we simply return that updated employee object with the status quo.
Or else if the employer object is null or empty, then we simply return a status quo to the client by
using Arias get method.
Well, it's pretty simple, right?
All right, great.
In next lecture, what you do is when a writer needs to test this update, employee or API.
All right.
I will see you in a next lecture.