/** * Compares two RelTraitSet objects to see if they match for the purposes of firing a rule. A null * RelTrait within a RelTraitSet indicates a wildcard: any RelTrait in the other RelTraitSet will * match. If one RelTraitSet is smaller than the other, comparison stops when the last RelTrait * from the smaller set has been examined and the remaining RelTraits in the larger set are * assumed to match. * * @param that another RelTraitSet * @return true if the RelTraitSets match, false otherwise */ public boolean matches(RelTraitSet that) { final int n = Math.min(this.size(), that.size()); for (int i = 0; i < n; i++) { RelTrait thisTrait = this.traits[i]; RelTrait thatTrait = that.traits[i]; if ((thisTrait == null) || (thatTrait == null)) { continue; } if (thisTrait != thatTrait) { return false; } } return true; }