code: public ModifyReplicationGroupShardConfigurationRequest withNodeGroupsToRetain(String... nodeGroupsToRetain) {
          if (this.nodeGroupsToRetain == null) {
              setNodeGroupsToRetain(new com.amazonaws.internal.SdkInternalList<String>(nodeGroupsToRetain.length));
          }
          for (String ele : nodeGroupsToRetain) {
              this.nodeGroupsToRetain.add(ele);
          }
          return this;
      }
docs: <p>
  If the value of <code>NodeGroupCount</code> is less than the current number of node groups (shards), the
  <code>NodeGroupsToRemove</code> or <code>NodeGroupsToRetain</code> is a required list of node group ids to remove
  from or retain in the cluster.
  </p>
  <p>
  ElastiCache for Redis will attempt to remove all node groups except those listed by
  <code>NodeGroupsToRetain</code> from the cluster.
  </p>
  <p>
  <b>NOTE:</b> This method appends the values to the existing list (if any). Use
  {@link #setNodeGroupsToRetain(java.util.Collection)} or {@link #withNodeGroupsToRetain(java.util.Collection)} if
  you want to override the existing values.
  </p>
  
  @param nodeGroupsToRetain
  If the value of <code>NodeGroupCount</code> is less than the current number of node groups (shards), the
  <code>NodeGroupsToRemove</code> or <code>NodeGroupsToRetain</code> is a required list of node group ids to
  remove from or retain in the cluster.</p>
  <p>
  ElastiCache for Redis will attempt to remove all node groups except those listed by
  <code>NodeGroupsToRetain</code> from the cluster.
  @return Returns a reference to this object so that method calls can be chained together.