Skip to content

Commit

Permalink
Added generic specification to avoid weird linkage error in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
João Neves committed Oct 26, 2017
1 parent 91ea678 commit 097e9d5
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.premiumminds.billy.core.exceptions.BillyValidationException;
import com.premiumminds.billy.core.services.builders.impl.TaxBuilderImpl;
import com.premiumminds.billy.core.services.entities.Context;
import com.premiumminds.billy.core.util.BillyValidator;
import com.premiumminds.billy.core.util.Localizer;
import com.premiumminds.billy.portugal.persistence.dao.DAOPTRegionContext;
Expand Down Expand Up @@ -50,7 +51,9 @@ protected PTTaxEntity getTypeInstance() {
protected void validateInstance() throws BillyValidationException {
PTTaxEntity e = this.getTypeInstance();

BillyValidator.mandatory(e.getContext(), PTTaxBuilderImpl.LOCALIZER.getString("field.tax_context"));
// The <Context> generic is necessary because type inference fails here for some unknown reason
// If removed, this line of code will fail in runtime with a linkage error (ClassCastException)
BillyValidator.<Context>mandatory(e.getContext(), PTTaxBuilderImpl.LOCALIZER.getString("field.tax_context"));
BillyValidator.mandatory(e.getTaxRateType(), PTTaxBuilderImpl.LOCALIZER.getString("field.tax_rate_type"));
BillyValidator.mandatory(e.getCode(), PTTaxBuilderImpl.LOCALIZER.getString("field.tax_code"));
BillyValidator.mandatory(e.getDescription(), PTTaxBuilderImpl.LOCALIZER.getString("field.tax_description"));
Expand Down

0 comments on commit 097e9d5

Please sign in to comment.