public void setPartitionAttributes(PartitionAttributes partition) {
    if (partition != null) {
      if (!regionAttributes.hasDataPolicy()) {
        regionAttributes.dataPolicy = PartitionedRegionHelper.DEFAULT_DATA_POLICY;
      } else if (!PartitionedRegionHelper.ALLOWED_DATA_POLICIES
          .contains(regionAttributes.dataPolicy)) {
        throw new IllegalStateException(
            String.format(
                "Data policy %s is not allowed for a partitioned region. DataPolicies other than %s are not allowed.",
                regionAttributes.dataPolicy,
                PartitionedRegionHelper.ALLOWED_DATA_POLICIES));
      }
      if (regionAttributes.hasPartitionAttributes()
          && regionAttributes.partitionAttributes instanceof PartitionAttributesImpl
          && partition instanceof PartitionAttributesImpl) {
        // Make a copy and call merge on it to prevent bug 51616
        PartitionAttributesImpl copy =
            ((PartitionAttributesImpl) regionAttributes.partitionAttributes).copy();
        copy.merge((PartitionAttributesImpl) partition);
        regionAttributes.partitionAttributes = copy;
      } else {
        regionAttributes.partitionAttributes = partition;
        regionAttributes.setHasPartitionAttributes(true);
      }

      ((PartitionAttributesImpl) regionAttributes.partitionAttributes)
          .setOffHeap(regionAttributes.offHeap);
    } else {
      regionAttributes.partitionAttributes = null;
      regionAttributes.setHasPartitionAttributes(false);
    }
  }
Sets the {@code PartitionAttributes} that describe how the region is partitioned among members
of the distributed system. This also establishes a data policy of {@link DataPolicy#PARTITION
PARTITION}, if the data policy has not already been set.

@param partition the {@code PartitionAttributes} that describe how the region is partitioned
       among members of the distributed system

@since GemFire 5.0
geode-core/src/main/java/org/apache/geode/cache/AttributesFactory.java