{"id":17993892,"url":"https://github.com/timandy/linq","last_synced_at":"2025-05-16T07:05:24.167Z","repository":{"id":37692489,"uuid":"98953540","full_name":"timandy/linq","owner":"timandy","description":"LINQ to Objects for Java.","archived":false,"fork":false,"pushed_at":"2024-11-04T08:09:41.000Z","size":3687,"stargazers_count":225,"open_issues_count":3,"forks_count":45,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-08T16:09:27.756Z","etag":null,"topics":["android","functional-programming","java","lambda","linq","linq4j","stream-api","tuple"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timandy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-01T03:06:30.000Z","updated_at":"2025-03-05T08:46:12.000Z","dependencies_parsed_at":"2023-12-18T03:31:03.526Z","dependency_job_id":"53d1fcc8-ff2c-43c2-b372-d723f33c1ae9","html_url":"https://github.com/timandy/linq","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Flinq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Flinq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Flinq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timandy%2Flinq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timandy","download_url":"https://codeload.github.com/timandy/linq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485057,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","functional-programming","java","lambda","linq","linq4j","stream-api","tuple"],"created_at":"2024-10-29T20:13:22.548Z","updated_at":"2025-05-16T07:05:19.158Z","avatar_url":"https://github.com/timandy.png","language":"Java","readme":"\u003c!--README FILE--\u003e\n# LINQ to Objects (Java)\n\n[![Build Status](https://github.com/timandy/linq/workflows/build/badge.svg)](https://github.com/timandy/linq/actions)\n[![Codecov](https://codecov.io/gh/timandy/linq/branch/master/graph/badge.svg)](https://codecov.io/gh/timandy/linq)\n[![Maven Central](https://img.shields.io/maven-central/v/com.bestvike/linq.svg)](https://search.maven.org/artifact/com.bestvike/linq)\n[![GitHub release](https://img.shields.io/github/release/timandy/linq.svg)](https://github.com/timandy/linq/releases/latest)\n[![License](https://img.shields.io/github/license/timandy/linq.svg)](https://github.com/timandy/linq/blob/master/LICENSE)\n\n[中文文档](README_CN.md)\n\nThe term \"LINQ to Objects\" refers to the use of LINQ queries with any `IEnumerable\u003cT\u003e`.\nYou can use LINQ to query any enumerable collections such as `Primitive Array`, `Object Array`, `List`, `Collection` or `Iterable` and so on.\nThe collection may be user-defined or may be returned by a JDK API.\n\nIn a basic sense, LINQ to Objects represents a new approach to collections.\nIn the old way, you had to write complex `foreach` loops that specified how to retrieve data from a collection.\nIn the LINQ approach, you write declarative code that describes what you want to retrieve.\n\nIn addition, LINQ queries offer two main advantages over traditional `foreach` loops:\n1. They are more concise and readable, especially when filtering multiple conditions.\n2. They provide powerful filtering, ordering, and grouping capabilities with a minimum of application code.\n\nLINQ queries also have some advantages over stream API:\n1. Support `foreach` loops therefore you can break loop at any time.\n2. IEnumerable can be traversed repeatedly.\n3. LINQ is very easy to use, like `ToCollection`, `LeftJoin` and so on.\n4. LINQ is faster than stream API in most complicated cases.\n\nIn general, the more complex the operation you want to perform on the data, the more benefit you will realize by using LINQ instead of traditional iteration techniques.\n\n## Features\n- Implemented all API of LINQ to Objects.\n- More API and Tuple supported.\n- Support for converting between IEnumerable and Stream.\n- Android supported.\n\n![bestvike](logo.jpg \"济南百思为科信息工程有限公司\")\n\n## Navigation\n![linq](linq.svg \"LINQ to Objects\")\n\n## API of Linq\n- empty\n- singleton\n- ofNullable\n- of\n- as\n- chars\n- words\n- lines\n- split\n- infinite\n- loop\n- enumerate\n- iterate\n- range\n- repeat\n\n## API of IEnumerable\n- `forEach`\n- `stream`\n- `parallelStream`\n- aggregate\n- all\n- any\n- append\n- asEnumerable\n- average\n- cast\n- chunk\n- concat\n- contains\n- count\n- `crossJoin`\n- defaultIfEmpty\n- distinct\n- `distinctBy`\n- elementAt\n- elementAtOrDefault\n- except\n- `exceptBy`\n- `findIndex`\n- `findLastIndex`\n- first\n- firstOrDefault\n- `format`\n- `fullJoin`\n- groupBy\n- groupJoin\n- `indexOf`\n- intersect\n- `intersectBy`\n- join\n- `joining`\n- last\n- `lastIndexOf`\n- lastOrDefault\n- `leftJoin`\n- longCount\n- max\n- `maxBy`\n- min\n- `minBy`\n- ofType\n- orderBy\n- orderByDescending\n- prepend\n- reverse\n- `rightJoin`\n- `runOnce`\n- select\n- selectMany\n- sequenceEqual\n- `shuffle`\n- single\n- singleOrDefault\n- skip\n- skipLast\n- skipWhile\n- sum\n- take\n- takeLast\n- takeWhile\n- toArray\n- `toCollection`\n- `toEnumeration`\n- `toLinkedList`\n- `toLinkedMap`\n- `toLinkedSet`\n- toList\n- toLookup\n- toMap\n- toSet\n- union\n- `unionBy`\n- where\n- zip\n\n## API of IGrouping extends IEnumerable\n- getKey\n\n## API of ILookup extends IEnumerable\n- getCount\n- get\n- containsKey\n\n## API of IOrderedEnumerable extends IEnumerable\n- thenBy\n- thenByDescending\n\n## API of Index\n- fromStart\n- fromEnd\n- getValue\n- isFromEnd\n- getOffset\n\n## API of Range\n- startAt\n- endAt\n- getStart\n- getEnd\n- getOffsetAndLength\n\n## Tuple classes\n- Tuple1\n- Tuple2\n- Tuple3\n- Tuple4\n- Tuple5\n- Tuple6\n- Tuple7\n- TupleN\n\n## Debug View (IntelliJ IDEA)\n1. Open the settings dialog `File | Settings | Build, Execution, Deployment | Debugger | Data Views | Java Type Renderers`.\n2. Click the `Add` button.\n3. Type `IterableView` in `Renderer name`.\n4. Type `java.lang.Iterable` in `Apply renderer to objects of type (fully-qualified name):`.\n5. In the `When rendering a node` section, check `Use following expression:` and type `DebugView.getDebuggerDisplayText(this)`.\n    If you get an error, press `Alt + Enter` to import the class.\n6. Check `Use list of expression:` and type `**RESULT VIEW**` in the `Name` column.\n    Type `DebugView.getDebuggerProxyObject(this)` in the `Expression` column.\n    If you get an error, press `Alt + Enter` to import the class.\n    It is recommended to check `On-demand` to enumerate the sequence if necessary.\n7. If you want to see the default field of the `Iterable` instance, check `Append default children`.\n8. Save your settings and try it out!\n\n`Result view should be used with caution because of possible side-effects.`\n\n## Maven\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.bestvike\u003c/groupId\u003e\n    \u003cartifactId\u003elinq\u003c/artifactId\u003e\n    \u003cversion\u003e6.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Gradle\n```\nimplementation 'com.bestvike:linq:6.0.0'\n```\n\n## Usage\n`If you use java 8 or java 9, it is recommended to replace the complex return type with lombok.var or lombok.val.\nIf you use java 10 or later, it is recommended to replace the complex return type with var.`\n\n- Join not empty strings.\n```\nString result = Linq.of(\"!@#$%^\", \"C\", \"AAA\", \"\", \"Calling Twice\", \"SoS\", Empty)\n        .where(x -\u003e x != null \u0026\u0026 x.length() \u003e 0)\n        .aggregate((x, y) -\u003e x + \", \" + y);\n\nSystem.out.println(result);\n----\n!@#$%^, C, AAA, Calling Twice, SoS\n```\n\n- Determine all positive numbers is even or not.\n```\nboolean result = Linq.of(9999, 0, 888, -1, 66, -777, 1, 2, -12345)\n        .where(x -\u003e x \u003e 0)\n        .all(x -\u003e x % 2 == 0);\n\nSystem.out.println(result);\n----\nfalse\n```\n\n- Determine any positive number is even or not.\n```\nboolean result = Linq.of(9999, 0, 888, -1, 66, -777, 1, 2, -12345)\n        .where(x -\u003e x \u003e 0)\n        .any(x -\u003e x % 2 == 0);\n\nSystem.out.println(result);\n----\ntrue\n```\n\n- Append a number at the end and insert two numbers in the header.\n```\nString result = Linq.range(3, 2).append(5).prepend(2).prepend(1).format();\n\nSystem.out.println(result);\n----\n[1, 2, 3, 4, 5]\n```\n\n- Compute average of integer sequence.\n```\ndouble result = Linq.of(5, -10, 15, 40, 28).averageInt();\n\nSystem.out.println(result);\n----\n15.6\n```\n\n- Concat two integer sequence.\n```\nString result = Linq.of(1, 2).concat(Linq.of(3, 4)).format();\n\nSystem.out.println(result);\n----\n[1, 2, 3, 4]\n```\n\n## *License*\nLINQ to Objects (Java) is released under the [Apache License 2.0](LICENSE).\n```\nCopyright 2017-2024 济南百思为科信息工程有限公司\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimandy%2Flinq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimandy%2Flinq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimandy%2Flinq/lists"}