WEBVTT

00:00.870 --> 00:01.380
Hi everyone.

00:01.380 --> 00:02.550
Welcome back to this tutorial.

00:02.550 --> 00:07.290
In this tutorial we will code and explore the by predicate example.

00:07.290 --> 00:10.290
So by predicate is again a functional interface.

00:10.530 --> 00:12.270
Let's go ahead and explore that.

00:14.290 --> 00:17.770
It's part of the Java Radial dot function package.

00:17.980 --> 00:18.760
Click on that.

00:18.760 --> 00:21.850
Buy predicate is also similar to predicate.

00:21.880 --> 00:28.210
It has one method called test and it is accepting two inputs, but the return type is the same.

00:28.210 --> 00:33.580
It is going to return the boolean and it has another default method called and.

00:34.460 --> 00:39.620
A gate and or it has all the default method, whatever the predicate has.

00:39.920 --> 00:42.860
And it is going to behave the same as the predicate.

00:42.890 --> 00:47.290
The only difference is by predicate is for two input parameters.

00:47.300 --> 00:49.790
Predicate is for one input parameter.

00:50.680 --> 00:56.620
So in this example, what we coded as part of the previous tutorial here, we have a condition.

00:56.620 --> 01:03.340
We are using two different predicates in order to apply the filtering on the student list.

01:03.370 --> 01:09.490
Now what I'm going to do, I'm going to create a bi predicate instance and then use that bi predicate

01:09.490 --> 01:14.590
instance to apply the filtering of students from the student list.

01:15.400 --> 01:16.100
Masterpiece.

01:16.630 --> 01:18.600
Let's create the by predicate instance.

01:18.610 --> 01:20.980
If you take a look at it, the first one is an integer.

01:21.010 --> 01:22.660
The second one is a double, right?

01:22.820 --> 01:25.300
So let's define the types integer.

01:26.230 --> 01:27.040
And double.

01:27.760 --> 01:31.000
I'm going to name this one as my predicate.

01:31.360 --> 01:34.510
Now we have to pass into two values, right?

01:34.540 --> 01:38.830
The first one is grade level can give any value you want.

01:38.950 --> 01:40.670
It's just like a reference variable.

01:40.690 --> 01:42.100
The next thing is GPA.

01:44.290 --> 01:48.280
And then what it is going to do, it is going to check.

01:49.130 --> 01:51.140
The grade level.

01:52.880 --> 01:55.090
Is greater than or equal to three.

01:56.250 --> 01:56.940
And.

01:58.470 --> 02:03.070
GPA is greater than or equal to 3.9.

02:03.090 --> 02:06.720
So we are performing these two checks as part of this, right?

02:06.720 --> 02:12.450
So since it is a single line statement, you don't even have to provide the curly braces as part of

02:12.450 --> 02:13.470
the lambda body.

02:13.590 --> 02:19.470
So once this is evaluated, if this is true, true boolean result will be returned.

02:19.470 --> 02:23.940
If it is false, then false Boolean result will be returned as part of this.

02:24.120 --> 02:27.510
The next step is instead of this what I'm going to do.

02:28.640 --> 02:31.520
Going to call this dot test.

02:31.940 --> 02:33.530
We have to pass the inputs.

02:33.530 --> 02:37.220
The first one, if you take a look at it, it is a grade level, right?

02:37.250 --> 02:41.330
Get grade level, comma, student dot.

02:42.540 --> 02:43.880
Get GPA.

02:46.400 --> 02:52.640
And then is going to behave as let's go ahead and run this one and then check whether is it giving us

02:52.640 --> 02:55.430
the same result as it was prior to the by predicate?

02:58.000 --> 02:58.480
There you go.

02:58.510 --> 03:00.850
It printed the same result as before.

03:00.880 --> 03:07.090
We want you can create a multiple bike predicate instances and then you can use the and operation.

03:07.270 --> 03:14.260
So if you press command space or sorry, control space, it will give you all these different operations

03:14.260 --> 03:15.130
it supports.

03:15.220 --> 03:22.450
You can use and you can use n number of and or you can use or or different methods.

03:26.300 --> 03:26.660
Okay.

03:26.660 --> 03:28.190
I'm going to remove this for now.

03:31.840 --> 03:34.030
So this is all about by predicate.

03:34.060 --> 03:34.900
By predicate.

03:34.930 --> 03:40.300
To summarize this by predicate is basically is going to accept two parameters and perform some kind

03:40.300 --> 03:44.880
of operation on the input, whatever that is being passed to that by predicate instance.

03:44.890 --> 03:48.340
And it is going to return a Boolean value as a result.

03:48.370 --> 03:50.410
With this, we came to the end of this tutorial.

03:50.440 --> 03:51.460
Thank you for watching.
