@Override public void notify(Path path, PathChildrenCacheEvent event) { events.add(new Pair<>(path, event)); }
Class<?> valClass = getValueClass(); if (valClass != null) { Pair<Class<?>, Class<?>> key = new Pair<>(valClass, arg.getClass()); Constructor<?> cstr = constructorCache.get(key); if (cstr == null) { if (!constructorCache.containsKey(key)) { try { cstr = valClass.getConstructor(key.getSecond()); constructorCache.put(key, cstr); } catch (NoSuchMethodException e) {
/** * Returns the class registered for the given identifier. * * @param id The identifer whose class to return. * @return The class specification, may be null. */ private Class<? extends Identifiable> get(int id) { Pair<Class<? extends Identifiable>, Constructor<? extends Identifiable>> pair = typeMap.get(id); return (pair != null) ? pair.getFirst() : null; }
/** For testing only */ public Set<String> getInjectedComponentIds() { Set<String> injectedIds = new HashSet<>(); for (Pair<String, Component> injected : injectedComponents) { injectedIds.add(injected.getSecond().getSubId()); } return injectedIds; }
@Override public String toString() { StringBuilder ret = new StringBuilder(); ret.append("select_input { "); for (Pair<String, Expression> entry : cases) { ret.append(entry.getFirst()).append(": "); Expression exp = entry.getSecond(); ret.append(exp).append("; "); } ret.append("}"); return ret.toString(); }
public void injectForName(String name, Component component) { injectedComponents.add(new Pair<>(name, component)); }
private boolean hasReference(CompoundName name) { if (references == null) return false; for (Pair<CompoundName, CompiledQueryProfile> reference : references) if (reference.getFirst().equals(name)) return true; return false; }
/** * Creates an instance of the class mapped to by the given identifier. This method proxies {@link * #createFromClass(Constructor)}. * * @param id The id of the class to create. * @return The instantiated object. */ private Identifiable createFromId(int id) { Pair<Class<? extends Identifiable>, Constructor<? extends Identifiable>> pair = typeMap.get(id); return createFromClass((pair != null) ? pair.getSecond() : null); }
public Map<String, String> getDocMap(String docType) { Map<String, String> cached = docMapCache.get(docType); if (cached!=null) { return cached; } Map<String, String> ret = new HashMap<>(); for (Entry<Pair<String, String>, String> e : fieldMap.entrySet()) { // Remember to include tuple if doctype is unset in mapping if (docType.equals(e.getKey().getFirst()) || e.getKey().getFirst()==null || "".equals(e.getKey().getFirst())) { ret.put(e.getKey().getSecond(), e.getValue()); } } docMapCache.put(docType, ret); return ret; }
@Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; Map<String, Pair<String, String>> fieldToClassAndSource = new HashMap<>(); for (DocumentSummary summary : search.getSummaries().values()) { if ("default".equals(summary.getName())) continue; for (SummaryField summaryField : summary.getSummaryFields() ) { if (summaryField.isImplicit()) continue; Pair<String, String> prevClassAndSource = fieldToClassAndSource.get(summaryField.getName()); for (Source source : summaryField.getSources()) { if (prevClassAndSource!=null) { String prevClass = prevClassAndSource.getFirst(); String prevSource = prevClassAndSource.getSecond(); if ( ! prevClass.equals(summary.getName())) { if ( ! prevSource.equals(source.getName())) { throw new IllegalArgumentException("For search '"+ search.getName() + "', summary class '" + summary.getName()+"'," + " summary field '" + summaryField.getName() + "':" + " Can not use source '" + source.getName() + "' for this summary field, an equally named field in summary class '" + prevClass + "' uses a different source: '"+prevSource+"'."); } } } else { fieldToClassAndSource.put(summaryField.getName(), new Pair<>(summary.getName(), source.getName())); } } } } }
private Pair<CompoundName, CompiledQueryProfile> findReference(CompoundName name) { if (references == null) return null; for (Pair<CompoundName, CompiledQueryProfile> entry : references) { if (name.hasPrefix(entry.getFirst())) return entry; } return null; }
@Override public void selectMembers(ObjectPredicate predicate, ObjectOperation operation) { for (Pair<String, Expression> entry : cases) { select(entry.getSecond(), predicate, operation); } }
private Compressor.Compression compress(List<Pair<String, String>> properties) { StringBuilder b = new StringBuilder(); for (Pair<String, String> property : properties) b.append(property.getFirst()).append(keyEndMarker).append(property.getSecond()).append(valueEndMarker); return compressor.compress(b.toString().getBytes(Charset.forName("utf8"))); }
} else { AsyncExecution asyncFill = new AsyncExecution(chainExecution); futureFilledResults.add(new Pair<>(resultToFill, asyncFill.fill(resultToFill, summaryClass))); Optional<Result> filledResult = futureFilledResult.getSecond().getIfAvailable(result.getQuery().getTimeLeft(), TimeUnit.MILLISECONDS); if (filledResult.isPresent()) { // fill completed propagateErrors(filledResult.get(), result); result.hits().addError(futureFilledResult.getSecond().createTimeoutError()); for (Iterator<Hit> i = futureFilledResult.getFirst().hits().unorderedDeepIterator(); i.hasNext(); ) {
protected List<Pair<Type, List<Annotation>>> getAnnotatedConstructorParams() { Type[] types = constructor.getGenericParameterTypes(); Annotation[][] annotations = constructor.getParameterAnnotations(); List<Pair<Type, List<Annotation>>> ret = new ArrayList<>(); for (int i = 0; i < types.length; i++) { ret.add(new Pair<>(types[i], Arrays.asList(annotations[i]))); } return ret; }