Validate method
Validates this transition group.
Implementation
@override
void Validate() {
// There must be exactly one or two transitions in the group.
if (transitions.isEmpty || transitions.length > 2) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
// If there is only one transition, it must be of type TimeZoneTransition
if (transitions.length == 1 &&
!(transitions[0].runtimeType == TimeZoneTransition)) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
// If there are two transitions, none of them should be of type TimeZoneTransition
if (transitions.length == 2) {
for (TimeZoneTransition transition in transitions) {
if (transition.runtimeType == TimeZoneTransition) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
}
}
// All the transitions in the group must be to a period.
for (TimeZoneTransition transition in transitions) {
if (transition.TargetPeriod == null) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
}
}