package net.brutex.xservices.util;

import lombok.NonNull;
import net.brutex.xservices.types.alfevent.ALFEventType;

/**
 * This example filter cuts the eventid to max of 32 characters
 */
public class EventIdTruncateFilter implements ALFEventFilter {
    /**
     * Modify or filter the alf event.
     *
     * @param event
     * @return modified event or null if it should be filtered out
     */
    @Override
    public ALFEventType filter(@NonNull ALFEventType event) {
    if (event.getBase().getEventId().length() > 32) {
      event.getBase().setEventId(event.getBase().getEventId().substring(0, 32));
        }
        return event;
    }
}
