Validate method

void Validate()
override
Validates this transition group.

Implementation

void Validate() {
  // There must be exactly one or two transitions in the group.
  if (this.transitions.length < 1 || this.transitions.length > 2) {
    throw new ServiceLocalException(
        "Strings.InvalidOrUnsupportedTimeZoneDefinition");
  }

  // If there is only one transition, it must be of type TimeZoneTransition
  if (this.transitions.length == 1 &&
      !(this.transitions[0].runtimeType == TimeZoneTransition)) {
    throw new ServiceLocalException(
        "Strings.InvalidOrUnsupportedTimeZoneDefinition");
  }

  // If there are two transitions, none of them should be of type TimeZoneTransition
  if (this.transitions.length == 2) {
    for (TimeZoneTransition transition in this.transitions) {
      if (transition.runtimeType == TimeZoneTransition) {
        throw new ServiceLocalException(
            "Strings.InvalidOrUnsupportedTimeZoneDefinition");
      }
    }
  }

  // All the transitions in the group must be to a period.
  for (TimeZoneTransition transition in this.transitions) {
    if (transition.TargetPeriod == null) {
      throw new ServiceLocalException(
          "Strings.InvalidOrUnsupportedTimeZoneDefinition");
    }
  }
}