public BucketReplicationConfiguration addRule(String id,
            ReplicationRule rule) {
        if (id == null || id.trim().isEmpty()) {
            throw new IllegalArgumentException(
                    "Rule id cannot be null or empty.");
        }
        if (rule == null) {
            throw new IllegalArgumentException(
                    "Replication rule cannot be null");
        }
        rules.put(id, rule);
        return this;
    }
Adds a new rule to the replication configuration associated with this
Amazon S3 bucket. Returns the updated object.

@param id
           the id for the rule.
@param rule
           the replication rule for the Amazon S3 bucket.
@throws IllegalArgumentException
            if the given id or rule is null.
@return the updated {@link BucketReplicationConfiguration} object.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/BucketReplicationConfiguration.java