class DestroyRegionCommand extends GfshCommand {

  void checkForJDBCMapping(String regionPath) {
    String regionName = regionPath;
    if (regionPath.startsWith(SEPARATOR)) {
      regionName = regionPath.substring(1);
    }
    InternalConfigurationPersistenceService ccService = getConfigurationPersistenceService();
    if (ccService == null) {
      return;
    }

    Set<String> groupNames = new HashSet<>(ccService.getGroups());
    groupNames.add("cluster");
    for (String groupName : groupNames) {
      CacheConfig cacheConfig = ccService.getCacheConfig(groupName);
      if (cacheConfig != null) {
        RegionConfig regionConfig = find(cacheConfig.getRegions(), regionName);
        if (regionConfig != null) {
          Identifiable<?> element =
              find(regionConfig.getCustomRegionElements(), "jdbc-mapping");
          if (element != null) {
            throw new IllegalStateException("Cannot destroy region \"" + regionName
                + "\" because JDBC mapping exists. Use \"destroy jdbc-mapping\" first.");
          }
        }
      }
    }
  }

}