src/main/java/org/primefaces/model/timeline/TimelineModel.java
/**
     * Merge the given one event with the given collection of events with UI update. Only events within one group can be merged.
     * Note: after merging, the merged event will get the same properties as the given one event except start and end dates.
     *
     * @param event           given event to be merged with collection of events
     * @param events          collection of events
     * @param timelineUpdater TimelineUpdater instance to update the merged events in UI
     * @return TimelineEvent result event after merging
     * @throws IllegalStateException thrown if not all events are within the same group
     */
Merge the given one event with the given collection of events with UI update. Only events within one group can be merged.
Note: after merging, the merged event will get the same properties as the given one event except start and end dates.


Merge the given one event with the given collection of events with UI update . Only events within one group can be merged . Note : after merging the merged event will get the same properties as the given one event except start and end dates .
public TimelineEvent<E> merge(TimelineEvent<E> event, Collection<TimelineEvent<E>> events, TimelineUpdater timelineUpdater) {
        if (event == null) {
            return null;
        }
        if (events == null || events.isEmpty()) {
            return event;
        }
        String group = event.getGroup();
        for (TimelineEvent<E> e : events) {
            if ((group == null && e.getGroup() != null) || (group != null && !group.equals(e.getGroup()))) {
                throw new IllegalStateException("Events to be merged may be only belong to one and the same group!");
            }
        }
        TreeSet<TimelineEvent<E>> orderedEvents = new TreeSet<>(new TimelineEventComparator());
        orderedEvents.add(event);
        orderedEvents.addAll(events);
        LocalDateTime endDate = orderedEvents.stream()
                .map(TimelineEvent::getEndDate)
                .filter(Objects::nonNull)
                .max(LocalDateTime::compareTo)
                .orElse(null);
        TimelineEvent<E> mergedEvent = new TimelineEvent<>(event.getData(), orderedEvents.first().getStartDate(), endDate, event.isEditable(),
                        event.getGroup(), event.getStyleClass());
        deleteAll(events, timelineUpdater);
        update(mergedEvent, timelineUpdater);
        return mergedEvent;
    }
public TimelineEvent < E > merge ( TimelineEvent < E > event , Collection < TimelineEvent < E > > events , TimelineUpdater timelineUpdater ) { if ( event == null ) { return null ; } if ( events == null || events . isEmpty ( ) ) { return event ; } String group = event . getGroup ( ) ; for ( TimelineEvent < E > e : events ) { if ( ( group == null && e . getGroup ( ) != null ) || ( group != null && ! group . equals ( e . getGroup ( ) ) ) ) { throw new IllegalStateException ( "Events to be merged may be only belong to one and the same group!" ) ; } } TreeSet < TimelineEvent < E > > orderedEvents = new TreeSet < > ( new TimelineEventComparator ( ) ) ; orderedEvents . add ( event ) ; orderedEvents . addAll ( events ) ; LocalDateTime endDate = orderedEvents . stream ( ) . map ( TimelineEvent :: getEndDate ) . filter ( Objects :: nonNull ) . max ( LocalDateTime :: compareTo ) . orElse ( null ) ; TimelineEvent < E > mergedEvent = new TimelineEvent < > ( event . getData ( ) , orderedEvents . first ( ) . getStartDate ( ) , endDate , event . isEditable ( ) , event . getGroup ( ) , event . getStyleClass ( ) ) ; deleteAll ( events , timelineUpdater ) ; update ( mergedEvent , timelineUpdater ) ; return mergedEvent ; }
Merge the given one event with the given collection of events with UI update.
Merge the given one event with the given collection of events with UI update .
// nothing to merge // nothing to merge // check whether all events within the same group // order events according to their start / end dates // find the largest end date // merge...