if (!primaryType.matches(item, th)) { String s = "The " + RoleDiagnostic.ordinal(count) + " item is not an instance of the required type"; Optional<String> more = primaryType.explainMismatch(item, th); if (more.isPresent()) { s = count == 1 ? more.get() : s + ". " + more.get();
if (!primaryType.matches(item, th)) { String s = "The " + RoleDiagnostic.ordinal(count) + " item is not an instance of the required type"; Optional<String> more = primaryType.explainMismatch(item, th); if (more.isPresent()) { s = count == 1 ? more.get() : s + ". " + more.get();
/** * Construct a full error message, displaying the item in error (suitable for use when * a type error is reported dynamically) * * @param requiredItemType the item type required by the context of a particular expression * @param item the actual item in error. Must NOT be null (unlike earlier releases). * @return a message of the form "Required item type of A is R; supplied value has item type S" */ public String composeErrorMessage(ItemType requiredItemType, Item item, TypeHierarchy th) { FastStringBuffer message = new FastStringBuffer(256); message.append(composeRequiredMessage(requiredItemType)); message.append("; the supplied value "); message.append(Err.depict(item)); if (requiredItemType.getGenre() != item.getGenre()) { message.append(" is "); message.append(item.getGenre().getDescription()); } else { message.append(" does not match. "); if (th != null) { Optional<String> more = requiredItemType.explainMismatch(item, th); more.ifPresent(message::append); } } return message.toString(); }
/** * Construct a full error message, displaying the item in error (suitable for use when * a type error is reported dynamically) * * @param requiredItemType the item type required by the context of a particular expression * @param item the actual item in error. Must NOT be null (unlike earlier releases). * @return a message of the form "Required item type of A is R; supplied value has item type S" */ public String composeErrorMessage(ItemType requiredItemType, Item item, TypeHierarchy th) { FastStringBuffer message = new FastStringBuffer(256); message.append(composeRequiredMessage(requiredItemType)); message.append("; the supplied value "); message.append(Err.depict(item)); if (requiredItemType.getGenre() != item.getGenre()) { message.append(" is "); message.append(item.getGenre().getDescription()); } else { message.append(" does not match. "); if (th != null) { Optional<String> more = requiredItemType.explainMismatch(item, th); more.ifPresent(message::append); } } return message.toString(); }