class InMemoryEntityFilter implements Predicate<ArchivedMessage> {

    @Override
    public boolean test(ArchivedMessage message) {
        EntityFilter.Type type = filter.type();
        if (type == EntityFilter.Type.TO_AND_FROM) {
            return matchToAndFrom(message);
        } else if (type == EntityFilter.Type.TO_OR_FROM) {
            return matchToOrFrom(message);
        } else {
            throw new IllegalArgumentException("Unexpected entity filter type '" + type + "'");
        }
    }

    public  InMemoryEntityFilter(EntityFilter filter);

}