@Override public Object apply(final Object p1, final Object p2) { return Pair.<Object, Object>of(p1, p2); } };
protected <T extends Object> void addCallback(final String methodId, final Consumer<T> callback, final Class<T> parameterType) { synchronized (this.notificationCallbackMap) { Pair<Class<?>, Consumer<?>> _mappedTo = Pair.<Class<?>, Consumer<?>>of(parameterType, callback); this.notificationCallbackMap.put(methodId, _mappedTo); } }
private Pair<String, String> getNameParts(final String string) { final char dot = '.'; final int index = string.lastIndexOf(dot); if ((index != (-1))) { String _substring = string.substring(0, index); String _substring_1 = string.substring((index + 1)); return Pair.<String, String>of(_substring, _substring_1); } else { return Pair.<String, String>of(null, string); } }
public String getThingWorxDataType(final String vortoType) { String dataType = ""; Pair<String, String> _mappedTo = Pair.<String, String>of("base64Binary", "BLOB"); Pair<String, String> _mappedTo_1 = Pair.<String, String>of("boolean", "BOOLEAN"); Pair<String, String> _mappedTo_2 = Pair.<String, String>of("dateTime", "DATETIME"); Pair<String, String> _mappedTo_3 = Pair.<String, String>of("int", "INTEGER"); Pair<String, String> _mappedTo_4 = Pair.<String, String>of("short", "INTEGER"); Pair<String, String> _mappedTo_5 = Pair.<String, String>of("long", "INTEGER"); Pair<String, String> _mappedTo_6 = Pair.<String, String>of("byte", "INTEGER"); Pair<String, String> _mappedTo_7 = Pair.<String, String>of("double", "NUMBER"); Pair<String, String> _mappedTo_8 = Pair.<String, String>of("float", "NUMBER"); Pair<String, String> _mappedTo_9 = Pair.<String, String>of("string", "STRING"); final HashMap<String, String> typeMap = CollectionLiterals.<String, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3, _mappedTo_4, _mappedTo_5, _mappedTo_6, _mappedTo_7, _mappedTo_8, _mappedTo_9); String _get = typeMap.get(vortoType); dataType = _get; boolean _equals = Objects.equal(dataType, null); if (_equals) { dataType = "UNDEFINED"; } return dataType; } }
@Override public void accept(final ContentAssistEntry entry, final int priority) { if ((entry != null)) { String _proposal = entry.getProposal(); boolean _tripleEquals = (_proposal == null); if (_tripleEquals) { throw new IllegalArgumentException("proposal must not be null."); } Pair<Integer, ContentAssistEntry> _mappedTo = Pair.<Integer, ContentAssistEntry>of(Integer.valueOf(priority), entry); proposals.add(_mappedTo); } }
@Override public void accept(final ContentAssistEntry entry, final int priority) { if ((entry != null)) { String _proposal = entry.getProposal(); boolean _tripleEquals = (_proposal == null); if (_tripleEquals) { throw new IllegalArgumentException("proposal must not be null."); } Pair<Integer, ContentAssistEntry> _mappedTo = Pair.<Integer, ContentAssistEntry>of(Integer.valueOf(priority), entry); this.entries.add(_mappedTo); } }
@SuppressWarnings("unchecked") @Test public void testSetLiteral_6() throws Exception { assertEvaluatesTo(newHashSet(Pair.of("foo", "bar")), "{ val java.util.Set x = #{'foo' -> 'bar'} x }"); }
/** * The <code>mappedTo</code> operator yields a {@link Pair} with {@code a} as the {@link Pair#getKey() key} and * {@code b} as its {@link Pair#getValue() value}. * * @param a * an object. * @param b * another object. * @return a {@link Pair}. Never <code>null</code>. */ @Pure @Inline(value="$3.$4of($1, $2)", imported=Pair.class) public static <A, B> Pair<A, B> operator_mappedTo(A a, B b) { return Pair.of(a, b); }
/** * The <code>mappedTo</code> operator yields a {@link Pair} with {@code a} as the {@link Pair#getKey() key} and * {@code b} as its {@link Pair#getValue() value}. * * @param a * an object. * @param b * another object. * @return a {@link Pair}. Never <code>null</code>. */ @Pure @Inline(value="$3.$4of($1, $2)", imported=Pair.class) public static <A, B> Pair<A, B> operator_mappedTo(A a, B b) { return Pair.of(a, b); }
public Iterable<ITypeDescriptor> getDescriptors(final ClassLoader classLoader, final Collection<String> packagePrefixes) { try { synchronized (this) { if ((this.classLoaderDescriptors == null)) { this.classLoaderDescriptors = this.createClassLoaderCache(); } } Pair<ClassLoader, Collection<String>> _mappedTo = Pair.<ClassLoader, Collection<String>>of(classLoader, packagePrefixes); final Callable<Iterable<ITypeDescriptor>> _function = () -> { return this.loadDescriptors(classLoader, packagePrefixes); }; return this.classLoaderDescriptors.get(_mappedTo, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public Iterable<ITypeDescriptor> getDescriptors(final URI uri, final Collection<String> packagePrefixes) { try { synchronized (this) { if ((this.uriDescriptors == null)) { this.uriDescriptors = this.createUriCache(); } } Pair<URI, Collection<String>> _mappedTo = Pair.<URI, Collection<String>>of(uri, packagePrefixes); final Callable<Iterable<ITypeDescriptor>> _function = () -> { return this.loadDescriptors(uri, packagePrefixes); }; return this.uriDescriptors.get(_mappedTo, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private static Pair<IRuntimeClasspathEntry, Integer> getJreEntry(IRuntimeClasspathEntry[] entries, List<IRuntimeClasspathEntry> bootEntriesPrepend) { int index = 0; IRuntimeClasspathEntry jreEntry = null; while (jreEntry == null && index < entries.length) { final IRuntimeClasspathEntry entry = entries[index++]; if (entry.getClasspathProperty() == IRuntimeClasspathEntry.BOOTSTRAP_CLASSES || entry.getClasspathProperty() == IRuntimeClasspathEntry.STANDARD_CLASSES) { if (JavaRuntime.isVMInstallReference(entry)) { jreEntry = entry; } else { bootEntriesPrepend.add(entry); } } } return Pair.of(jreEntry, index); }
protected <T> T internalGet(String methodName, Provider<T> provider, Object... elements) { return cache.<T> get( Pair.<String, Object> of(methodName, cacheUtils.getKeys(elements)), cacheUtils.getResource(elements), provider); }
protected void withOutputConfig(final BuildRequest it, final Procedure1<? super OutputConfiguration> init) { Set<OutputConfiguration> _outputConfigurations = this.configurationProvider.getOutputConfigurations(); final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(_outputConfigurations); init.apply(config); Pair<String, Set<OutputConfiguration>> _mappedTo = Pair.<String, Set<OutputConfiguration>>of(this.languageName, Collections.<OutputConfiguration>unmodifiableSet(CollectionLiterals.<OutputConfiguration>newHashSet(config))); final OutputConfigurationAdapter adapter = new OutputConfigurationAdapter(Collections.<String, Set<OutputConfiguration>>unmodifiableMap(CollectionLiterals.<String, Set<OutputConfiguration>>newHashMap(_mappedTo))); XtextResourceSet _resourceSet = it.getResourceSet(); EList<Adapter> _eAdapters = _resourceSet.eAdapters(); _eAdapters.add(adapter); }
protected void registerMacroAnnotations(final XtendAnnotationTarget candidate, final IAcceptor<Pair<JvmAnnotationType, XAnnotation>> acceptor) { final Function1<XAnnotation, Boolean> _function = (XAnnotation it) -> { return Boolean.valueOf(this._xAnnotationExtensions.isProcessed(it)); }; Iterable<XAnnotation> _filter = IterableExtensions.<XAnnotation>filter(candidate.getAnnotations(), _function); for (final XAnnotation annotation : _filter) { { final JvmAnnotationType activeAnnotationDeclaration = this._xAnnotationExtensions.tryFindAnnotationType(annotation); if ((activeAnnotationDeclaration != null)) { boolean _isValid = this.isValid(annotation, activeAnnotationDeclaration); if (_isValid) { Pair<JvmAnnotationType, XAnnotation> _mappedTo = Pair.<JvmAnnotationType, XAnnotation>of(activeAnnotationDeclaration, annotation); acceptor.accept(_mappedTo); } } } } }
private Iterable<Pair<String, String>> getProjectMappings() { final Function1<ISubProjectConfig, Boolean> _function = (ISubProjectConfig it) -> { return Boolean.valueOf(((it.getName() != null) && (it.getRoot() != null))); }; final Function1<ISubProjectConfig, Pair<String, String>> _function_1 = (ISubProjectConfig it) -> { String _name = it.getName(); String _path = it.getRoot().getPath(); return Pair.<String, String>of(_name, _path); }; return IterableExtensions.map(IterableExtensions.filter(this.projectConfig.getEnabledProjects(), _function), _function_1); }
protected Map<String, JvmTypeReference> _collectDeclaredVariablesTypeMap(final TestStepWithAssignment testStep) { InteractionType _interaction = this._tclModelUtil.getInteraction(testStep); MethodReference _defaultMethod = null; if (_interaction!=null) { _defaultMethod=_interaction.getDefaultMethod(); } JvmOperation _operation = null; if (_defaultMethod!=null) { _operation=_defaultMethod.getOperation(); } JvmTypeReference _returnType = null; if (_operation!=null) { _returnType=_operation.getReturnType(); } final JvmTypeReference typeReference = _returnType; String _name = testStep.getVariable().getName(); Pair<String, JvmTypeReference> _mappedTo = Pair.<String, JvmTypeReference>of(_name, typeReference); return Collections.<String, JvmTypeReference>unmodifiableMap(CollectionLiterals.<String, JvmTypeReference>newHashMap(_mappedTo)); }
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))); }
/** * Obtain a document from the session store, and if it is not present there, ask the * {@link IServerResourceHandler} to provide it. In case that resource handler fails * to provide the document, {@code null} is returned instead. */ protected XtextWebDocument getResourceDocument(final String resourceId, final IServiceContext context) { try { ISession _session = context.getSession(); Pair<Class<XtextWebDocument>, String> _mappedTo = Pair.<Class<XtextWebDocument>, String>of(XtextWebDocument.class, resourceId); final Function0<XtextWebDocument> _function = () -> { try { return this.resourceHandler.get(resourceId, context); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; final XtextWebDocument document = _session.<XtextWebDocument>get(_mappedTo, _function); return document; } catch (final Throwable _t) { if (_t instanceof IOException) { return null; } else { throw Exceptions.sneakyThrow(_t); } } }
/** * Revert the content of a document to the last saved state. */ public ResourceContentResult revert(final String resourceId, final IServerResourceHandler resourceHandler, final IServiceContext serviceContext) throws InvalidRequestException { try { final XtextWebDocument document = resourceHandler.get(resourceId, serviceContext); ISession _session = serviceContext.getSession(); Pair<Class<XtextWebDocument>, String> _mappedTo = Pair.<Class<XtextWebDocument>, String>of(XtextWebDocument.class, resourceId); _session.put(_mappedTo, document); String _text = document.getText(); String _stateId = document.getStateId(); return new ResourceContentResult(_text, _stateId, false); } catch (final Throwable _t) { if (_t instanceof IOException) { final IOException ioe = (IOException)_t; throw new InvalidRequestException.ResourceNotFoundException("The requested resource was not found.", ioe); } else { throw Exceptions.sneakyThrow(_t); } } }