public static <T> T getFromMap(Map<UniformItemPath, T> map, UniformItemPath itemPath) { for (Map.Entry<UniformItemPath, T> entry : map.entrySet()) { if (entry.getKey().equivalent(itemPath)) { return entry.getValue(); } } return null; } }
public static <T> T putToMap(Map<UniformItemPath, T> map, UniformItemPath itemPath, T value) { for (UniformItemPath key : map.keySet()) { if (key.equivalent(itemPath)) { return map.put(key, value); } } return map.put(itemPath, value); }
/** * Finds all the options for given path. TODO could there be more than one? * Returns live objects that could be modified by client. */ @NotNull public static <T> Collection<T> findOptionsForPath(Collection<SelectorOptions<T>> options, @NotNull UniformItemPath path) { Collection<T> rv = new ArrayList<>(); for (SelectorOptions<T> oooption: CollectionUtils.emptyIfNull(options)) { if (path.equivalent(oooption.getItemPathOrNull())) { rv.add(oooption.getOptions()); } } return rv; }
@Test public void testXPathSerializationToDom() { // GIVEN QName qname1 = new QName(NS_C, "extension"); QName qname2 = new QName(NS_FOO, "foo"); ItemPathHolder itemPathHolder1 = ItemPathHolder.createForTesting(qname1, qname2); QName elementQName = new QName(NS_BAR, "bar"); // WHEN Element element = itemPathHolder1.toElement(elementQName, DOMUtil.getDocument()); ItemPathHolder itemPathHolder2 = ItemPathHolder.createForTesting(element); // THEN System.out.println("XPath from QNames:"); System.out.println(DOMUtil.serializeDOMToString(element)); UniformItemPath xpath1 = itemPathHolder1.toItemPath(); UniformItemPath xpath2 = itemPathHolder2.toItemPath(); assertTrue("Paths are not equivalent", xpath1.equivalent(xpath2)); }
} else if (paging.getOrderingInstructions().size() == 1) { ItemPath orderBy = paging.getOrderBy(); if (CREATED_PATH.equivalent(orderBy)) { taskQuery = taskQuery.orderByTaskCreateTime(); } else {
if (params.isFixTarget() && mappingOutputPathUniform != null && defaultTargetItemPath != null && !mappingOutputPathUniform.equivalent(defaultTargetItemPath)) { throw new ExpressionEvaluationException("Target cannot be overridden in "+mappingDesc); if (params.isFixTarget() && mappingOutputPath != null && defaultTargetItemPath != null && !mappingOutputPath.equivalent(defaultTargetItemPath)) { throw new ExpressionEvaluationException("Target cannot be overridden in "+mappingDesc);