private Pair<CommaSeparatedValuesExpectationImpl, CharSequence> expandVariables( CommaSeparatedValuesExpectationImpl csvE, XpEnvironmentData data) { // val CommaSeparatedValuesExpectationImpl csvE = (expectation as CommaSeparatedValuesExpectationImpl); IExpectationRegion region = csvE.getRegion(); CharSequence doc = region.getDocument(); CharSequence expectedText = null; if (region.getLength() < 0) { expectedText = ""; } else { expectedText = doc.subSequence(region.getOffset(), region.getOffset() + region.getLength()); } CommaSeparatedValuesExpectationCfg cfg = new CommaSeparatedValuesExpectationCfg(csvE.getAnnotation()); cfg.setData(data); VarSubstCommaSeparatedValuesExpectationImpl csvRet = new VarSubstCommaSeparatedValuesExpectationImpl(csvE, cfg); VarSubstExpectationCollection vseColl = new VarSubstExpectationCollection(data); vseColl.init(expectedText.toString()); String expandedExpectedText = IteratorExtensions.join(vseColl.iterator(), ","); return new Pair<>(csvRet, expandedExpectedText); }
protected List<Class<?>> getExtensionClasses() { return Lists.<Class<?>> newArrayList( ArrayExtensions.class, BigDecimalExtensions.class, BigIntegerExtensions.class, BooleanExtensions.class, ByteExtensions.class, CharacterExtensions.class, CollectionExtensions.class, ComparableExtensions.class, DoubleExtensions.class, FloatExtensions.class, FunctionExtensions.class, IntegerExtensions.class, IterableExtensions.class, IteratorExtensions.class, ListExtensions.class, LongExtensions.class, MapExtensions.class, ObjectExtensions.class, ProcedureExtensions.class, ShortExtensions.class, StringExtensions.class); }
@Test public void testToMap() { List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>(); pairs.add(new Pair<Integer, String>(1, "A")); pairs.add(new Pair<Integer, String>(1, "a")); pairs.add(new Pair<Integer, String>(2, "B")); pairs.add(new Pair<Integer, String>(2, "b")); Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() { @Override public Integer apply(Pair<Integer, String> p) { return p.getKey(); } }; Map<Integer, Pair<Integer, String>> map = IteratorExtensions.toMap(pairs.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 2, map.size()); Assert.assertTrue("Contains 1 as key", map.keySet().contains(1)); Assert.assertEquals("Contains entry 1->a for key 1", map.get(1), new Pair<Integer, String>(1, "a")); Assert.assertTrue("Contains 2 as key", map.keySet().contains(2)); Assert.assertEquals("Contains entry 2->b for key 2", map.get(2), new Pair<Integer, String>(2, "b")); }
@Test public void testToMap__WhenCalculatedKeyNull() { List<String> names = new ArrayList<String>(); names.add("Mueller"); names.add("Schneider"); names.add("Schmidt"); names.add("Koch"); Function1<String, String> computeKeys = new Function1<String, String>() { @Override public String apply(String p) { return p.contains("y") ? "y" : null; } }; Map<String, String> map = IteratorExtensions.toMap(names.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 1, map.size()); Assert.assertTrue("Contains null as key", map.keySet().contains(null)); Assert.assertEquals("Contains entry Koch for key null", "Koch", map.get(null)); }
@Test public void testToMap__WhenNoValuesForKey() { List<String> names = new ArrayList<String>(); names.add("Mueller"); names.add("Schneider"); names.add("Schmidt"); names.add("Koch"); Function1<String, Boolean> computeKeys = new Function1<String, Boolean>() { @Override public Boolean apply(String p) { return p.contains("y"); } }; Map<Boolean, String> map = IteratorExtensions.toMap(names.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 1, map.size()); Assert.assertTrue("Contains FALSE as key", map.keySet().contains(Boolean.FALSE)); Assert.assertTrue("Contains entry Mueller for key FALSE", map.get(Boolean.FALSE).equals("Koch")); Assert.assertNull("Contains no entry for key Boolean.TRUE", map.get(Boolean.TRUE)); }
@Test public void testGroupBy() { List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>(); pairs.add(new Pair<Integer, String>(1, "A")); pairs.add(new Pair<Integer, String>(1, "a")); pairs.add(new Pair<Integer, String>(2, "B")); pairs.add(new Pair<Integer, String>(2, "b")); Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() { @Override public Integer apply(Pair<Integer, String> p) { return p.getKey(); } }; Map<Integer, List<Pair<Integer, String>>> map = IteratorExtensions.groupBy(pairs.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 2, map.size()); Assert.assertTrue("Contains 1 as key", map.keySet().contains(1)); Assert.assertEquals("Contains 2 entries for key 1", 2, map.get(1).size()); Assert.assertEquals("Contains entry 1->A for key 1", new Pair<Integer, String>(1, "A"), map.get(1).get(0)); Assert.assertEquals("Contains entry 1->a for key 1", new Pair<Integer, String>(1, "a"), map.get(1).get(1)); Assert.assertTrue("Contains 2 as key", map.keySet().contains(2)); Assert.assertEquals("Contains 2 entries for key 2", 2, map.get(2).size()); Assert.assertEquals("Contains entry 2->B for key 2", new Pair<Integer, String>(2, "B"), map.get(2).get(0)); Assert.assertEquals("Contains entry 2->b for key 2", new Pair<Integer, String>(2, "b"), map.get(2).get(1)); }
@Test public void testGroupBy__WhenCalculatedKeyNull() { List<String> names = new ArrayList<String>(); names.add("Mueller"); names.add("Schneider"); names.add("Schmidt"); names.add("Koch"); Function1<String, String> computeKeys = new Function1<String, String>() { @Override public String apply(String p) { return p.contains("y") ? "y" : null; } }; Map<String, List<String>> map = IteratorExtensions.groupBy(names.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 1, map.size()); Assert.assertTrue("Contains null as key", map.keySet().contains(null)); Assert.assertEquals("Contains 4 entries for key null", 4, map.get(null).size()); }
@Test public void testGroupBy__WhenNoValuesForKey() { List<String> names = new ArrayList<String>(); names.add("Mueller"); names.add("Schneider"); names.add("Schmidt"); names.add("Koch"); Function1<String, Boolean> computeKeys = new Function1<String, Boolean>() { @Override public Boolean apply(String p) { return p.contains("y"); } }; Map<Boolean, List<String>> map = IteratorExtensions.groupBy(names.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 1, map.size()); Assert.assertTrue("Contains FALSE as key", map.keySet().contains(Boolean.FALSE)); Assert.assertEquals("Contains 4 entries for key Boolean.FALSE", 4, map.get(Boolean.FALSE).size()); Assert.assertTrue("Contains entry Mueller for key FALSE", map.get(Boolean.FALSE).contains("Mueller")); Assert.assertNull("Contains no entry for key Boolean.TRUE", map.get(Boolean.TRUE)); }
@Override public void doGenerate(final Resource resource, final IFileSystemAccess fsa) { TreeIterator<EObject> _allContents = resource.getAllContents(); Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_allContents); Iterable<ExpressionsModel> _filter = Iterables.<ExpressionsModel>filter(_iterable, ExpressionsModel.class); final Procedure1<ExpressionsModel> _function = new Procedure1<ExpressionsModel>() { @Override public void apply(final ExpressionsModel it) { StringConcatenation _builder = new StringConcatenation(); URI _uRI = resource.getURI(); String _lastSegment = _uRI.lastSegment(); _builder.append(_lastSegment, ""); _builder.append(".evaluated"); String _interpretExpressions = ExpressionsGenerator.this.interpretExpressions(it); fsa.generateFile(_builder.toString(), _interpretExpressions); } }; IterableExtensions.<ExpressionsModel>forEach(_filter, _function); }
@Override public void doGenerate(final Resource resource, final IFileSystemAccess fsa) { TreeIterator<EObject> _allContents = resource.getAllContents(); Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_allContents); Iterable<Entity> _filter = Iterables.<Entity>filter(_iterable, Entity.class); final Procedure1<Entity> _function = new Procedure1<Entity>() { @Override public void apply(final Entity it) { StringConcatenation _builder = new StringConcatenation(); _builder.append("entities/"); String _name = it.getName(); _builder.append(_name, ""); _builder.append(".java"); CharSequence _compile = EntitiesGenerator.this.compile(it); fsa.generateFile(_builder.toString(), _compile); } }; IterableExtensions.<Entity>forEach(_filter, _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Iterator<YieldExpression> getAllVoidYieldExpressions() { final Function1<YieldExpression, Boolean> _function = new Function1<YieldExpression, Boolean>() { public Boolean apply(final YieldExpression it) { Expression _expression = it.getExpression(); return Boolean.valueOf((_expression == null)); } }; return IteratorExtensions.<YieldExpression>filter(this.getAllYieldExpressions(), _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Iterator<YieldExpression> getAllNonVoidYieldExpressions() { final Function1<YieldExpression, Boolean> _function = new Function1<YieldExpression, Boolean>() { public Boolean apply(final YieldExpression it) { Expression _expression = it.getExpression(); return Boolean.valueOf((_expression != null)); } }; return IteratorExtensions.<YieldExpression>filter(this.getAllYieldExpressions(), _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Iterator<ReturnStatement> getAllNonVoidReturnStatements() { final Function1<ReturnStatement, Boolean> _function = new Function1<ReturnStatement, Boolean>() { public Boolean apply(final ReturnStatement it) { Expression _expression = it.getExpression(); return Boolean.valueOf((_expression != null)); } }; return IteratorExtensions.<ReturnStatement>filter(this.getAllReturnStatements(), _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Iterator<ReturnStatement> getAllVoidReturnStatements() { final Function1<ReturnStatement, Boolean> _function = new Function1<ReturnStatement, Boolean>() { public Boolean apply(final ReturnStatement it) { Expression _expression = it.getExpression(); return Boolean.valueOf((_expression == null)); } }; return IteratorExtensions.<ReturnStatement>filter(this.getAllReturnStatements(), _function); }
public void compilar() { StringBuilder sb = new StringBuilder(); Iterable<Ingrediente> _filter = Iterables.<Ingrediente>filter(IteratorExtensions.<EObject>toIterable(this.resource.getAllContents()), Ingrediente.class); for (final Ingrediente i : _filter) { sb.append(this.compilarTexto(i)); } this.fsa.generateFile("ingredientes.txt", sb.toString()); Iterable<Restaurante> _filter_1 = Iterables.<Restaurante>filter(IteratorExtensions.<EObject>toIterable(this.resource.getAllContents()), Restaurante.class); for (final Restaurante r : _filter_1) { this.fsa.generateFile("resto_informacion.txt", this.compilarTexto(r)); } }
@Override public void doGenerate(final Resource input, final IFileSystemAccess fsa) { Iterable<Element> _filter = Iterables.<Element>filter(IteratorExtensions.<EObject>toIterable(input.getAllContents()), Element.class); for (final Element ele : _filter) { { if ((fsa instanceof IFileSystemAccess2)) { StringConcatenation _builder = new StringConcatenation(); String _name = ele.getName(); _builder.append(_name); _builder.append(".txt"); boolean _isFile = ((IFileSystemAccess2)fsa).isFile(_builder.toString()); if (_isFile) { StringConcatenation _builder_1 = new StringConcatenation(); String _name_1 = ele.getName(); _builder_1.append(_name_1); _builder_1.append(".txt"); ((IFileSystemAccess2)fsa).readTextFile(_builder_1.toString()); } } StringConcatenation _builder_2 = new StringConcatenation(); String _name_2 = ele.getName(); _builder_2.append(_name_2); _builder_2.append(".txt"); StringConcatenation _builder_3 = new StringConcatenation(); _builder_3.append("object "); String _name_3 = ele.getName(); _builder_3.append(_name_3); fsa.generateFile(_builder_2.toString(), _builder_3); } } }
protected List<XClosure> findClosures(final CharSequence expression) { try { final String expressionAsString = expression.toString().replace("ClosureTypeResolutionTestData", "org.eclipse.xtext.xbase.tests.typesystem.ClosureTypeResolutionTestData").replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(expressionAsString, false); final List<XClosure> Closures = IteratorExtensions.<XClosure>toList(Iterators.<XClosure>filter(EcoreUtil2.eAll(xExpression), XClosure.class)); final Function1<XClosure, Integer> _function = (XClosure it) -> { return Integer.valueOf(NodeModelUtils.findActualNodeFor(it).getOffset()); }; return IterableExtensions.<XClosure, Integer>sortBy(Closures, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected List<XAbstractFeatureCall> findFeatureCalls(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); final List<XAbstractFeatureCall> featureCalls = IteratorExtensions.<XAbstractFeatureCall>toList(Iterators.<XAbstractFeatureCall>filter(EcoreUtil2.eAll(xExpression), XAbstractFeatureCall.class)); final Function1<XAbstractFeatureCall, Integer> _function = (XAbstractFeatureCall it) -> { return Integer.valueOf(IterableExtensions.<INode>head(NodeModelUtils.findNodesForFeature(it, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE)).getOffset()); }; return IterableExtensions.<XAbstractFeatureCall, Integer>sortBy(featureCalls, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testImplicitReceiver() { ExpectationTestingTypeComputer _typeComputer = this.getTypeComputer(); final Function1<XExpression, Boolean> _function = (XExpression it) -> { return Boolean.valueOf(false); }; _typeComputer.setPredicate(_function); this.expects("{val it = 1L intValue}"); final XFeatureCall intValue = IteratorExtensions.<XFeatureCall>head(Iterators.<XFeatureCall>filter(this.rootExpression.eAllContents(), XFeatureCall.class)); XExpression _implicitReceiver = intValue.getImplicitReceiver(); this.expressions.add(_implicitReceiver); this.queriedAs("Long"); }
@Test public void testImplicitFirstArgument() { ExpectationTestingTypeComputer _typeComputer = this.getTypeComputer(); final Function1<XExpression, Boolean> _function = (XExpression it) -> { return Boolean.valueOf(false); }; _typeComputer.setPredicate(_function); this.expects("{val it = null as String[] head}"); final XFeatureCall size = IteratorExtensions.<XFeatureCall>head(Iterators.<XFeatureCall>filter(this.rootExpression.eAllContents(), XFeatureCall.class)); XExpression _implicitFirstArgument = size.getImplicitFirstArgument(); this.expressions.add(_implicitFirstArgument); this.queriedAs("Iterable<String>"); }
protected List<XConstructorCall> findConstructorCalls(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); Assert.assertTrue(xExpression.eResource().getErrors().isEmpty()); final List<XConstructorCall> closures = IteratorExtensions.<XConstructorCall>toList(Iterators.<XConstructorCall>filter(EcoreUtil2.eAll(xExpression), XConstructorCall.class)); final Function1<XConstructorCall, Integer> _function = (XConstructorCall it) -> { return Integer.valueOf(IterableExtensions.<INode>head(NodeModelUtils.findNodesForFeature(it, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR)).getOffset()); }; return IterableExtensions.<XConstructorCall, Integer>sortBy(closures, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected List<XStringLiteral> findLiterals(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); final List<XStringLiteral> featureCalls = IteratorExtensions.<XStringLiteral>toList(Iterators.<XStringLiteral>filter(EcoreUtil2.eAll(xExpression), XStringLiteral.class)); final Function1<XStringLiteral, Integer> _function = (XStringLiteral it) -> { return Integer.valueOf(NodeModelUtils.findActualNodeFor(it).getOffset()); }; return IterableExtensions.<XStringLiteral, Integer>sortBy(featureCalls, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testToMap__WhenEmptyList() { List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>(); Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() { @Override public Integer apply(Pair<Integer, String> p) { return p.getKey(); } }; Map<Integer, Pair<Integer, String>> map = IteratorExtensions.toMap(pairs.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 0, map.size()); }
@Test public void testGroupBy__WhenEmptyList() { List<Pair<Integer, String>> pairs = new ArrayList<Pair<Integer, String>>(); Function1<Pair<Integer, String>, Integer> computeKeys = new Function1<Pair<Integer, String>, Integer>() { @Override public Integer apply(Pair<Integer, String> p) { return p.getKey(); } }; Map<Integer, List<Pair<Integer, String>>> map = IteratorExtensions.groupBy(pairs.iterator(), computeKeys); Assert.assertEquals("Expected grouped map size", 0, map.size()); }
@Test public void testFlatMap () { ArrayList<String> list = newArrayList("foo", "bar"); final Functions.Function1<String, Iterator<String>> function = new Functions.Function1<String, Iterator<String>>() { @Override public Iterator<String> apply(String p) { return newArrayList("Hello", p).iterator(); } }; assertEquals(newArrayList("Hello", "foo", "Hello", "bar"), newArrayList(IteratorExtensions.flatMap(list.iterator(), function))); }
@Override public List<? extends ColoringInformation> getColoring(final XtextResource resource, final Document document) { if ((resource == null)) { return CollectionLiterals.<ColoringInformation>emptyList(); } final ImmutableList.Builder<ColoringInformation> builder = ImmutableList.<ColoringInformation>builder(); final Procedure1<Object> _function = (Object it) -> { List<INode> _xifexpression = null; if ((it instanceof Property)) { _xifexpression = NodeModelUtils.findNodesForFeature(((EObject)it), TestLanguagePackage.Literals.MEMBER__NAME); } else { List<INode> _xifexpression_1 = null; if ((it instanceof Operation)) { _xifexpression_1 = NodeModelUtils.findNodesForFeature(((EObject)it), TestLanguagePackage.Literals.MEMBER__NAME); } else { _xifexpression_1 = CollectionLiterals.<INode>emptyList(); } _xifexpression = _xifexpression_1; } final List<INode> nodes = _xifexpression; final Consumer<INode> _function_1 = (INode it_1) -> { final int start = it_1.getOffset(); int _offset = it_1.getOffset(); int _length = it_1.getLength(); final int end = (_offset + _length); Position _position = document.getPosition(start); Position _position_1 = document.getPosition(end); final Range range = new Range(_position, _position_1); ColoringInformation _coloringInformation = new ColoringInformation(range, ColoringServiceImpl.STYLE_IDS); builder.add(_coloringInformation); }; nodes.forEach(_function_1); }; IteratorExtensions.<Object>forEach(EcoreUtil.<Object>getAllContents(resource, true), _function); return builder.build(); }
@Override public void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { Iterator<Greeting> filtered = Iterators.filter(resource.getAllContents(), Greeting.class); Iterator<String> names = Iterators.transform(filtered, new Function<Greeting, String>() { @Override public String apply(Greeting greeting) { return greeting.getName(); } }); String fileName = resource.getURI().lastSegment(); if(fileName == null) fileName = "greetings"; fsa.generateFile(fileName+".txt", "People to greet: " + IteratorExtensions.join(names, ", ")); }
@Test public void testExplicitRuleCallsAreTracked() throws Exception { StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate test \'http://test\'"); _builder.newLine(); _builder.append("Rule: name=super::ID name=ID;"); _builder.newLine(); _builder.append("terminal ID: super;"); _builder.newLine(); _builder.append("terminal _super: \'s\';"); _builder.newLine(); final String grammarAsString = _builder.toString(); final XtextResource resource = this.getResourceFromString(grammarAsString); EObject _get = resource.getContents().get(0); Grammar grammar = ((Grammar) _get); final AbstractRule firstRule = IterableExtensions.<AbstractRule>head(grammar.getRules()); final RuleCall firstRuleCall = IteratorExtensions.<RuleCall>head(Iterators.<RuleCall>filter(firstRule.eAllContents(), RuleCall.class)); Assert.assertTrue(firstRuleCall.isExplicitlyCalled()); final RuleCall secondRuleCall = IteratorExtensions.<RuleCall>last(Iterators.<RuleCall>filter(firstRule.eAllContents(), RuleCall.class)); Assert.assertFalse(secondRuleCall.isExplicitlyCalled()); final RuleCall thirdRuleCall = IteratorExtensions.<RuleCall>head(Iterators.<RuleCall>filter(grammar.getRules().get(1).eAllContents(), RuleCall.class)); Assert.assertTrue(thirdRuleCall.isExplicitlyCalled()); resource.update(grammarAsString.indexOf("_super"), 1, " "); Assert.assertEquals(resource, firstRuleCall.eResource()); Assert.assertEquals(resource, secondRuleCall.eResource()); Assert.assertEquals(resource, thirdRuleCall.eResource()); resource.getContents(); Assert.assertFalse(thirdRuleCall.isExplicitlyCalled()); Assert.assertEquals(IterableExtensions.<AbstractRule>last(grammar.getRules()), thirdRuleCall.getRule()); }
public void compilar() { Iterable<Restaurante> _filter = Iterables.<Restaurante>filter(IteratorExtensions.<EObject>toIterable(this.resource.getAllContents()), Restaurante.class); for (final Restaurante r : _filter) { this.compilarTexto(r); } }
public void fireproof(final String input) throws Exception { try { final EObject file = this._parseHelper.parse(input); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file); Assert.assertNotNull(resolvedTypes); if ((file != null)) { Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(file.eAllContents()); for (final EObject content : _iterable) { boolean _matched = false; if (content instanceof XAbstractFeatureCall) { _matched=true; this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes); XExpression _implicitReceiver = ((XAbstractFeatureCall)content).getImplicitReceiver(); boolean _tripleNotEquals = (_implicitReceiver != null); if (_tripleNotEquals) { this.assertExpressionTypeIsResolved(((XAbstractFeatureCall)content).getImplicitReceiver(), resolvedTypes); } XExpression _implicitFirstArgument = ((XAbstractFeatureCall)content).getImplicitFirstArgument(); boolean _tripleNotEquals_1 = (_implicitFirstArgument != null); if (_tripleNotEquals_1) { this.assertExpressionTypeIsResolved(((XAbstractFeatureCall)content).getImplicitFirstArgument(), resolvedTypes); } } if (!_matched) { if (content instanceof XClosure) { _matched=true; this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes); final Consumer<JvmFormalParameter> _function = (JvmFormalParameter it) -> { this.assertIdentifiableTypeIsResolved(it, resolvedTypes); }; ((XClosure)content).getImplicitFormalParameters().forEach(_function); } } if (!_matched) { if (content instanceof XExpression) { _matched=true; this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes); } } if (!_matched) { if (content instanceof JvmIdentifiableElement) { _matched=true; this.assertIdentifiableTypeIsResolved(((JvmIdentifiableElement)content), resolvedTypes); } } } } } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable e = (Throwable)_t; String _message = e.getMessage(); final ComparisonFailure error = new ComparisonFailure(_message, input, ""); error.setStackTrace(e.getStackTrace()); throw error; } else { throw Exceptions.sneakyThrow(_t); } } }
protected Multimap<Class<?>, Class<?>> simpleComputeExtensionClasses() { Multimap<Class<?>, Class<?>> result = ArrayListMultimap.create(); result.put(String.class, StringExtensions.class); result.put(Double.TYPE, DoubleExtensions.class); result.put(Float.TYPE, FloatExtensions.class); result.put(Long.TYPE, LongExtensions.class); result.put(Integer.TYPE, IntegerExtensions.class); result.put(Character.TYPE, CharacterExtensions.class); result.put(Short.TYPE, ShortExtensions.class); result.put(Byte.TYPE, ByteExtensions.class); result.put(Boolean.TYPE, BooleanExtensions.class); result.put(double[].class, ArrayExtensions.class); result.put(float[].class, ArrayExtensions.class); result.put(long[].class, ArrayExtensions.class); result.put(int[].class, ArrayExtensions.class); result.put(char[].class, ArrayExtensions.class); result.put(short[].class, ArrayExtensions.class); result.put(byte[].class, ArrayExtensions.class); result.put(boolean[].class, ArrayExtensions.class); result.put(BigInteger.class, BigIntegerExtensions.class); result.put(BigDecimal.class, BigDecimalExtensions.class); result.put(Comparable.class, ComparableExtensions.class); result.put(Object.class, ObjectExtensions.class); result.put(List.class, ListExtensions.class); result.put(Collection.class, CollectionExtensions.class); result.put(Map.class, CollectionExtensions.class); result.put(Map.class, MapExtensions.class); result.put(Iterable.class, IterableExtensions.class); result.put(Iterator.class, IteratorExtensions.class); result.put(Functions.Function0.class, FunctionExtensions.class); result.put(Functions.Function1.class, FunctionExtensions.class); result.put(Functions.Function2.class, FunctionExtensions.class); result.put(Functions.Function3.class, FunctionExtensions.class); result.put(Functions.Function4.class, FunctionExtensions.class); result.put(Functions.Function5.class, FunctionExtensions.class); result.put(Functions.Function6.class, FunctionExtensions.class); result.put(Procedures.Procedure0.class, ProcedureExtensions.class); result.put(Procedures.Procedure1.class, ProcedureExtensions.class); result.put(Procedures.Procedure2.class, ProcedureExtensions.class); result.put(Procedures.Procedure3.class, ProcedureExtensions.class); result.put(Procedures.Procedure4.class, ProcedureExtensions.class); result.put(Procedures.Procedure5.class, ProcedureExtensions.class); result.put(Procedures.Procedure6.class, ProcedureExtensions.class); return result; }
@Test public void testToIterable() throws Exception { ArrayList<String> list = newArrayList("A","B"); for (String s : IteratorExtensions.toIterable(list.iterator())) { assertTrue(list.contains(s)); } }
@Override protected Iterator<Integer> operator_plus(Iterator<Integer> first, Iterator<Integer> second) { return IteratorExtensions.operator_plus(first, second); }
@Override protected Integer findFirst(Iterator<Integer> input, Function1<Integer, Boolean> filter) { return IteratorExtensions.findFirst(input, filter); }
@Override protected Integer findLast(Iterator<Integer> input, Function1<Integer, Boolean> filter) { return IteratorExtensions.findLast(input, filter); }
@Override protected Integer last(Iterator<Integer> input) { return IteratorExtensions.last(input); }
@Override protected Integer head(Iterator<Integer> input) { return IteratorExtensions.head(input); }
@Override protected void forEach(Iterator<Integer> input, Procedure2<Integer, Integer> proc) { IteratorExtensions.forEach(input, proc); }