public void setFilter(ReplicationFilter filter) {
        if (filter == null) {
            throw new IllegalArgumentException(
                    "Filter cannot be null for a replication rule");
        }
        if (prefix != null) {
            throw new IllegalArgumentException(
                    "You cannot use both prefix and filter at the same time in a replication rule");
        }
        this.filter = filter;
    }
Sets the {@link ReplicationFilter} that is used to identify objects that a CRR Rule applies to.
A rule cannot have both {@link ReplicationFilter} and the deprecated {@link #prefix}.

@param filter {@link ReplicationFilter}
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/ReplicationRule.java