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)
.window(TumblingEventTimeWindows.of(Time.minutes(5)))
.aggregate(new SampleFunction());

How can I do this with java?