class EventMerger {

  public MetaStoreEvent merge(MetaStoreEvent a, MetaStoreEvent b) {
    checkArgument(canMerge(a, b), "Events cannot be merged");
    // Event type of the first event is kept for the new event
    Builder builder = MetaStoreEvent
        .builder(a.getEventType(), a.getDatabaseName(), a.getTableName(), a.getReplicaDatabaseName(),
            a.getReplicaTableName())
        .parameters(a.getParameters())
        .parameters(b.getParameters())
        .environmentContext(a.getEnvironmentContext())
        .environmentContext(b.getEnvironmentContext());
    if (a.getPartitionColumns() != null) {
      builder.partitionColumns(a.getPartitionColumns());
    }
    if (a.getPartitionValues() != null) {
      a.getPartitionValues().stream().forEach(builder::partitionValues);
    }
    if (b.getPartitionValues() != null) {
      b.getPartitionValues().stream().forEach(builder::partitionValues);
    }
    // Ensure that cascade is preserved
    if (a.isCascade() || b.isCascade()) {
      builder.environmentContext(ImmutableMap.of(CASCADE, TRUE.toString()));
    }
    return builder.build();
  }

    EventMerger();

}