Getting the first and last element of every 5 minutes window time of a json stream of data

Hello everyone,

I have a stream of json data that calculate some values in every 5 minutes with TumblingEventTimeWindows, I want to get the first and the last value of these time windows.
Here a part of the code:

DataStream<????> result_stream = stream.keyBy(???::Id)
.aggregate(new SampleFunction());

How can I do this with java?