@SafeVarargs private static <K, V> void putAll(Map<K, V> result, Pair<? extends K, ? extends V>... entries) { for (Pair<? extends K, ? extends V> entry : entries) { if (result.containsKey(entry.getKey())) throw new IllegalArgumentException("duplicate key: " + entry.getKey()); result.put(entry.getKey(), entry.getValue()); } }
private static <K, V> void putAll(Map<K, V> result, Pair<? extends K, ? extends V>... entries) { for (Pair<? extends K, ? extends V> entry : entries) { if (result.containsKey(entry.getKey())) throw new IllegalArgumentException("duplicate key: " + entry.getKey()); result.put(entry.getKey(), entry.getValue()); } }
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Pair)) return false; Pair<?, ?> e = (Pair<?, ?>) o; return Objects.equal(k, e.getKey()) && Objects.equal(v, e.getValue()); }
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Pair)) return false; Pair<?, ?> e = (Pair<?, ?>) o; return Objects.equal(k, e.getKey()) && Objects.equal(v, e.getValue()); }
public static InputStream jarInputStream(Pair<String, InputStream> ...entries) { try { ByteArrayOutputStream out2 = new ByteArrayOutputStream(); JarOutputStream jo = new JarOutputStream(new BufferedOutputStream(out2)); for (Pair<String, InputStream> entry : entries) { JarEntry je = new JarEntry(entry.getKey()); jo.putNextEntry(je); ByteStreams.copy(entry.getValue(), jo); } jo.close(); return new ByteArrayInputStream(out2.toByteArray()); } catch (IOException e) { throw new WrappedException(e); } }
@Pure protected boolean isValidSubscriber(final Pair<Function1<? super Event, ? extends Boolean>, Set<BehaviorGuardEvaluator>> subscriber) { if (((subscriber != null) && (subscriber.getValue() != null))) { return ((this.skipSubscriberFiltering || (subscriber.getKey() == null)) || (subscriber.getKey().apply(this.event)).booleanValue()); } return false; }
private static <K extends Object, V extends Object> Map<K, V> toMap(final Iterable<Pair<K, V>> items) { LinkedHashMap<K, V> _xblockexpression = null; { final LinkedHashMap<K, V> result = CollectionLiterals.<K, V>newLinkedHashMap(); for (final Pair<K, V> i : items) { result.put(i.getKey(), i.getValue()); } _xblockexpression = result; } return _xblockexpression; }
private static FeatureReplacement matchFirstPattern(List<Pair<FeaturePattern, FeatureReplacement>> patterns, String source) { final LinkedList<String> sourceFeature = new LinkedList<>(); sourceFeature.add(source); for (final Pair<FeaturePattern, FeatureReplacement> patternMatching : patterns) { final FeaturePattern pattern = patternMatching.getKey(); if (pattern.isNameReplacement() && pattern.matches(sourceFeature)) { return patternMatching.getValue(); } } return null; }
@Override public void apply(final Button it) { it.setCaption(captionAndAction.getKey()); it.onClick(new Action() { public void execute() { onC.apply(); } }); } };
/** * filter from the given list of pairs all the ones where the value is (assignable to class) clazz */ public <A extends Object, B extends Object, C extends Object> Iterable<Pair<C, A>> filterValue(final Iterable<Pair<C, B>> unfiltered, final Class<A> clazz) { final Predicate<Pair<C, B>> _function = (Pair<C, B> it) -> { return clazz.isAssignableFrom(it.getValue().getClass()); }; final Function1<Pair<C, B>, Pair<C, A>> _function_1 = (Pair<C, B> it) -> { C _key = it.getKey(); B _value = it.getValue(); return new Pair<C, A>(_key, ((A) _value)); }; return IterableExtensions.<Pair<C, B>, Pair<C, A>>map(Iterables.<Pair<C, B>>filter(unfiltered, _function), _function_1); }
@Override public void run() { try { initializer.getValue().apply(initializer.getKey()); } catch (RuntimeException e) { operationCanceledManager.propagateAsErrorIfCancelException(e); LOG.error("Error calling inferrer", e); } } };
private String generateCallParameters(final TestStep step, final TemplateContainer templateContainer) { String _xblockexpression = null; { final List<Pair<StepContent, Optional<JvmTypeReference>>> stepContentsWithTypes = this.getVariablesWithTypesInOrder(step, templateContainer); final Function1<Pair<StepContent, Optional<JvmTypeReference>>, Iterable<String>> _function = (Pair<StepContent, Optional<JvmTypeReference>> it) -> { return this.toParameterString(it.getKey(), it.getValue(), templateContainer, true); }; _xblockexpression = IterableExtensions.join(Iterables.<String>concat(ListExtensions.<Pair<StepContent, Optional<JvmTypeReference>>, Iterable<String>>map(stepContentsWithTypes, _function)), ", "); } return _xblockexpression; }
@Override public CompletableFuture<?> request(String method, Object parameter) { Assert.assertTrue(expectedRequests.containsKey(method)); Pair<Object, Object> result = expectedRequests.remove(method); Assert.assertEquals(result.getKey().toString(), parameter.toString()); return CompletableFuture.completedFuture(result.getValue()); }
@Override public CompletableFuture<?> request(String method, Object parameter) { Assert.assertTrue(expectedRequests.containsKey(method)); Pair<Object, Object> result = expectedRequests.remove(method); Assert.assertEquals(result.getKey().toString(), parameter.toString()); return CompletableFuture.completedFuture(result.getValue()); }
/** * same as {@link #resourceSet(Pair...)} but without actually loading the created resources. */ public ResourceSet unLoadedResourceSet(@SuppressWarnings("unchecked") Pair<String,? extends CharSequence> ...resources ) throws IOException { XtextResourceSet result = newResourceSetWithUTF8Encoding(); for (Pair<String, ? extends CharSequence> entry : resources) { URI uri = copyToWorkspace(getSourceFolderPath()+"/"+entry.getKey(), entry.getValue()); Resource resource = result.createResource(uri); if (resource == null) throw new IllegalStateException("Couldn't create resource for URI "+uri+". Resource.Factory not registered?"); } return result; }
/** * check that each variable usage/deref is a known variable */ private void _checkAllReferencedVariablesAreKnown(final TestStep step, final Set<String> knownVariableNames, final String errorMessage) { final Function1<Pair<Integer, VariableReference>, Boolean> _function = (Pair<Integer, VariableReference> it) -> { boolean _contains = knownVariableNames.contains(it.getValue().getVariable().getName()); return Boolean.valueOf((!_contains)); }; final Iterable<Pair<Integer, VariableReference>> erroneousIndexedStepContents = IterableExtensions.<Pair<Integer, VariableReference>>filter(this._collectionUtils.<VariableReference, StepContent, Integer>filterValue(IterableExtensions.<StepContent>indexed(step.getContents()), VariableReference.class), _function); final Consumer<Pair<Integer, VariableReference>> _function_1 = (Pair<Integer, VariableReference> it) -> { this.error(errorMessage, it.getValue().eContainer(), it.getValue().eContainingFeature(), (it.getKey()).intValue(), TclValidator.INVALID_VAR_DEREF); }; erroneousIndexedStepContents.forEach(_function_1); }
@Override public void addError(final Element element, final String message) { this.checkCanceled(); this.checkValidationAllowed(); final Pair<Resource, EObject> resAndObj = this.getResourceAndEObject(element); EList<Resource.Diagnostic> _errors = resAndObj.getKey().getErrors(); EObject _value = resAndObj.getValue(); EStructuralFeature _significantFeature = this.getSignificantFeature(resAndObj.getValue()); EObjectDiagnosticImpl _eObjectDiagnosticImpl = new EObjectDiagnosticImpl(Severity.ERROR, "user.issue", message, _value, _significantFeature, (-1), null); _errors.add(_eObjectDiagnosticImpl); }
@Override public void addWarning(final Element element, final String message) { this.checkCanceled(); this.checkValidationAllowed(); final Pair<Resource, EObject> resAndObj = this.getResourceAndEObject(element); EList<Resource.Diagnostic> _warnings = resAndObj.getKey().getWarnings(); EObject _value = resAndObj.getValue(); EStructuralFeature _significantFeature = this.getSignificantFeature(resAndObj.getValue()); EObjectDiagnosticImpl _eObjectDiagnosticImpl = new EObjectDiagnosticImpl(Severity.WARNING, "user.issue", message, _value, _significantFeature, (-1), null); _warnings.add(_eObjectDiagnosticImpl); }
public NamedSerializationContextProvider(final Grammar grammar) { final Function1<Pair<Integer, ParserRule>, Pair<ParserRule, Integer>> _function = (Pair<Integer, ParserRule> it) -> { ParserRule _value = it.getValue(); Integer _key = it.getKey(); return Pair.<ParserRule, Integer>of(_value, _key); }; this.rules = CollectionLiterals.<ParserRule, Integer>newHashMap(((Pair<? extends ParserRule, ? extends Integer>[])Conversions.unwrapArray(IterableExtensions.<Pair<Integer, ParserRule>, Pair<ParserRule, Integer>>map(IterableExtensions.<ParserRule>indexed(GrammarUtil.allParserRules(grammar)), _function), Pair.class))); }
private void setup() { final StandaloneSetup delegate = new StandaloneSetup(); delegate.setScanClassPath(this.scanClasspath); final Consumer<Pair<String, String>> _function = (Pair<String, String> mapping) -> { ProjectMapping _projectMapping = new ProjectMapping(); final Procedure1<ProjectMapping> _function_1 = (ProjectMapping it) -> { it.setProjectName(mapping.getKey()); it.setPath(mapping.getValue()); }; ProjectMapping _doubleArrow = ObjectExtensions.<ProjectMapping>operator_doubleArrow(_projectMapping, _function_1); delegate.addProjectMapping(_doubleArrow); }; this.getProjectMappings().forEach(_function); }