protected void validate() throws InvalidDDMSException {
Util.requireDDMSQName(getXOMElement(), PostalAddress.getName(getDDMSVersion()));
if (!getDDMSVersion().isAtLeast("5.0")) {
Util.requireBoundedChildCount(getXOMElement(), STREET_NAME, 0, 6);
if (!Util.isEmpty(getState()) && !Util.isEmpty(getProvince())) {
throw new InvalidDDMSException("Only 1 of state or province must be used.");
}
// Check for TSPI components is implicit, since they cannot be instantiated before DDMS 5.0.
}
else {
if (!getStreets().isEmpty() || !Util.isEmpty(getCity()) || !Util.isEmpty(getState())
|| !Util.isEmpty(getProvince()) || !Util.isEmpty(getPostalCode()) || getCountryCode() != null) {
throw new InvalidDDMSException("postalAddress must be defined with a TSPI address.");
}
Util.requireDDMSValue("TSPI address", getTspiAddress());
}
super.validate();
}