@Override public Class<T> getType() { return valueCache.getType(); }
/** * Formats the error message in case of not unique match. This * allows data sources to give more specific error messages. * * @param cache the cache used for the match * @param connection the connection payload used for the match * @param match the result of the match * @param matchedConverters the matched converters; will either be 0 (no match) * or more than 1 (non unique match) * @return the message to be passed with the exception */ protected String formatMessage(ValueCache<?> cache, Object connection, int match, List<? extends DataSourceTypeAdapter<?, ?>> matchedConverters) { if (matchedConverters.isEmpty()) { return "DataSource misconfiguration: no match found to convert payload to type. (" + cache.getType() + " - " + connection + ")"; } else { return "DataSource misconfiguration: multiple matches found to convert payload to type. (" + cache.getType() + " - " + connection + ": " + matchedConverters + ")"; } } }
@Override public int match(ValueCache<?> cache, JCAConnectionPayload connPayload) { Channel channel = connPayload.getChannel(); // If the generated type can't be put in the cache, no match if (!cache.getType().isAssignableFrom(typeClass)) return 0; // If the type of the channel does not match, no match if (!dbrTypeMatch(epicsValueType, connPayload.getFieldType())) return 0; // If processes array, but count is 1, no match if (array != null &&array && channel.getElementCount() == 1) return 0; // If processes scalar, but the count is not 1, no match if (array != null && !array && channel.getElementCount() != 1) return 0; // Everything matches return 1; }
if (!cache.getType().isAssignableFrom(typeClass)) return 0;