Validate method
Validates this time zone definition.
Implementation
@override
void Validate() {
// The definition must have at least one period, one transition group and one transition,
// and there must be as many transitions as there are transition groups.
if (_periods.isEmpty ||
_transitions.isEmpty ||
_transitionGroups.isEmpty ||
_transitionGroups.length != _transitions.length) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
// The first transition must be of type TimeZoneTransition.
if (_transitions[0].runtimeType != TimeZoneTransition) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
// All transitions must be to transition groups and be either TimeZoneTransition or
// AbsoluteDateTransition instances.
for (TimeZoneTransition transition in _transitions) {
Type transitionType = transition.runtimeType;
if (transitionType != TimeZoneTransition &&
transitionType != AbsoluteDateTransition) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
if (transition.TargetGroup == null) {
throw ServiceLocalException(
"Strings.InvalidOrUnsupportedTimeZoneDefinition",
);
}
}
// All transition groups must be valid.
for (TimeZoneTransitionGroup transitionGroup in _transitionGroups.values) {
transitionGroup.Validate();
}
}