hashData method

bool hashData(
  1. Map data
)

Implementation

bool hashData(Map data) {
  int count_valid = 0;
  int count_data_same = 0;
  void countValid(Map data_origin) {
    data_origin.forEach((key, value) {
      if (value is Map) {
      } else if (value is List) {
        count_valid++;
      } else {
        count_valid++;
      }
    });
  }

  data.forEach((key, value) {
    if (value is Map) {
      countValid(value);
    } else if (value is List) {
      count_valid++;
    } else {
      count_valid++;
    }
  });

  void countSame(Map data_origin, Map data_old) {
    data_origin.forEach((key, value) {
      if (!data_origin.containsKey(key)) {
        return;
      }
      dynamic value_origin = data_origin[key];
      if (value is RegExp) {
        if (value.hashData(value_origin)) {
          count_data_same++;
        }
      } else if (value is Map) {
        if (value_origin is Map) {
          countSame(value, value_origin);
        }
      } else if (value is List) {
        if (value_origin is List) {
          if (value_origin.hashData(value)) {
            count_data_same++;
          }
        }
      } else {
        if (value_origin == value) {
          count_data_same++;
        }
      }
    });
  }

  data.forEach((key, value) {
    if (!containsKey(key)) {
      return;
    }
    dynamic value_origin = this[key];
    if (value is RegExp) {
      if (value.hashData(value_origin)) {
        count_data_same++;
      }
    } else if (value is Map) {
      if (value_origin is Map) {
        countSame(value, value_origin);
      }
    } else if (value is List) {
      if (value_origin is List) {
        if (value_origin.hashData(value)) {
          count_data_same++;
        }
      }
    } else {
      if (value_origin == value) {
        count_data_same++;
      }
    }
  });

  if (count_valid == 0) {
    return false;
  }
  return (count_valid == count_data_same);
}