toJson method

Map<String, Object> toJson()

Converts a TopologySpreadConstraint instance to JSON data.

Implementation

Map<String, Object> toJson() {
  final jsonData = <String, Object>{};

  final tempLabelSelector = labelSelector;
  final tempMatchLabelKeys = matchLabelKeys;
  final tempMaxSkew = maxSkew;
  final tempMinDomains = minDomains;
  final tempNodeAffinityPolicy = nodeAffinityPolicy;
  final tempNodeTaintsPolicy = nodeTaintsPolicy;
  final tempTopologyKey = topologyKey;
  final tempWhenUnsatisfiable = whenUnsatisfiable;

  if (tempLabelSelector != null) {
    jsonData['labelSelector'] = tempLabelSelector.toJson();
  }

  if (tempMatchLabelKeys != null) {
    jsonData['matchLabelKeys'] = tempMatchLabelKeys;
  }

  jsonData['maxSkew'] = tempMaxSkew;

  if (tempMinDomains != null) {
    jsonData['minDomains'] = tempMinDomains;
  }

  if (tempNodeAffinityPolicy != null) {
    jsonData['nodeAffinityPolicy'] = tempNodeAffinityPolicy;
  }

  if (tempNodeTaintsPolicy != null) {
    jsonData['nodeTaintsPolicy'] = tempNodeTaintsPolicy;
  }

  jsonData['topologyKey'] = tempTopologyKey;

  jsonData['whenUnsatisfiable'] = tempWhenUnsatisfiable;

  return jsonData;
}