{"id":15043171,"url":"https://github.com/trigersoft/jaque","last_synced_at":"2025-04-10T03:51:28.500Z","repository":{"id":21013621,"uuid":"24305524","full_name":"TrigerSoft/jaque","owner":"TrigerSoft","description":"Lets Java 8 Lambdas to be represented as objects in the form of expression trees at runtime","archived":false,"fork":false,"pushed_at":"2023-11-10T22:13:38.000Z","size":136,"stargazers_count":162,"open_issues_count":0,"forks_count":24,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-03T00:07:09.148Z","etag":null,"topics":["expression-tree","fluent-interface","java","java-8","lambda","linq"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TrigerSoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-09-21T21:48:51.000Z","updated_at":"2024-07-27T13:16:45.000Z","dependencies_parsed_at":"2024-10-12T15:40:49.793Z","dependency_job_id":"b8e4d6f8-fd34-4ca3-b5f5-d05d3418d05a","html_url":"https://github.com/TrigerSoft/jaque","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrigerSoft%2Fjaque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrigerSoft%2Fjaque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrigerSoft%2Fjaque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrigerSoft%2Fjaque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrigerSoft","download_url":"https://codeload.github.com/TrigerSoft/jaque/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246911497,"owners_count":20853657,"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":["expression-tree","fluent-interface","java","java-8","lambda","linq"],"created_at":"2024-09-24T20:48:39.711Z","updated_at":"2025-04-03T00:07:12.856Z","avatar_url":"https://github.com/TrigerSoft.png","language":null,"readme":"[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/TrigerSoft/jaque.svg)](http://isitmaintained.com/project/TrigerSoft/jaque \"Average time to resolve an issue\")\n[![Maven Central](https://img.shields.io/maven-central/v/com.trigersoft/jaque.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.trigersoft%22%20AND%20a:%22jaque%22)\n\nThe project is discontinued, but inspired a [strong successor](https://github.com/streamx-co/ExTree).\n\n# JAva QUEry\n\nThis library enables Java 8 Lambdas to be represented as objects in the form of expression trees at runtime:\n\n```java\nvoid method(Predicate\u003cCustomer\u003e p) {\n  LambdaExpression\u003cPredicate\u003cCustomer\u003e\u003e parsed = LambdaExpression.parse(p);\n  //Use parsed Expression Tree...\n}\n```\n\nmaking it possible to create type-safe fluent interfaces, i.e. instead of:\n\n```java\nCustomer obj = ...\nobj.property(\"name\").eq(\"John\")\n```\n\none can write\n\n```java\nmethod\u003cCustomer\u003e(obj -\u003e obj.getName() == \"John\")\n```\n\nin type-safe, refactoring friendly manner. And then the library developer will be able to parse the produced Lambda to the corresponding Expression Tree for analysis.\n\n---\n\nFor example, [JPA Criteria API](http://docs.oracle.com/javaee/6/tutorial/doc/gjivm.html) could benefit a lot from using JaQue, e.g.:\n\n```java\n//instead of this:\nRoot\u003cPet\u003e pet = cq.from(Pet.class);\nJoin\u003cPet, Owner\u003e owner = pet.join(Pet_.owners);\n\n//it could be this:\nJoin\u003cPet, Owner\u003e owner = pet.join(Pet::getOwners);\n\n//and instead of this:\nquery.where(pet.get(Pet_.color).isNull());\nquery.where(builder.equal(pet.get(Pet_.name), \"Fido\")\n\t.and(builder.equal(pet.get(Pet_.color), \"brown\")));\n\t\n//it could be this:\nquery.where(pet -\u003e pet.getColor() == null);\nquery.where(pet -\u003e (pet.getName() == \"Fido\") \u0026\u0026 (pet.getColor() == \"brown\"));\n```\n\nIf you are looking for an oportunity to start an open source project, implementing the above should be very beneficial for a very large developer comminuty. Should you start this or any other open source project based on JaQue, I'll be happy to [assist you](mailto://kostat@trigersoft.com).\n\n#### How to write fluent interface with JaQue?\n\n- Suppose you want to reference some class property\n\n```java\npublic class Fluent\u003cT\u003e {\n\n\t// this interface is required to make the lambda Serializable, which removes a need for \n\t// jdk.internal.lambda.dumpProxyClasses system property. See below.\n\tpublic static interface Property\u003cT, R\u003e extends Function\u003cT, R\u003e, Serializable {\n\t}\n\n\tpublic Fluent\u003cT\u003e property(Property\u003cT, ?\u003e propertyRef) {\n\t\tLambdaExpression\u003cFunction\u003cT, ?\u003e\u003e parsed = LambdaExpression\n\t\t\t\t.parse(propertyRef);\n\t\tExpression body = parsed.getBody();\n\t\tExpression methodCall = body;\n\t\t\n\t\t// remove casts\n\t\twhile (methodCall instanceof UnaryExpression)\n\t\t\tmethodCall = ((UnaryExpression) methodCall).getFirst();\n\n\t\t// checks are omitted for brevity\n\t\tMember member = ((MemberExpression) ((InvocationExpression) methodCall)\n\t\t\t\t.getTarget()).getMember();\n\t\t\n\t\t// use member\n\t\t...\n\t\t\n\t\treturn this;\n\t}\n}\n```\n\n- Now your users will be able to write\n\n```java\nFluent\u003cCustomer\u003e f = new Fluent\u003cCustomer\u003e();\nf.property(Customer::getName);\n```\n\n\u003e Make the lambda Serializable, as shown in example above. If the lambda is not serializable, the [jdk.internal.lambda.dumpProxyClasses](https://bugs.openjdk.java.net/browse/JDK-8023524) system property must be set and point to an existing writable directory to give the parser access to the lambda byte code.\n\n#### Resources\n\n- [Full Docs](http://trigersoft.github.io/jaque) [(noframes)](http://trigersoft.github.io/jaque/overview-summary.html)\n- [Maven Artifact](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22jaque%22)\n- [Technical Details](https://github.com/TrigerSoft/jaque/wiki/Technical-Details)\n- [Quality Assurance and Continuous Integration](https://github.com/TrigerSoft/jaque/wiki/Quality-Assurance)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrigersoft%2Fjaque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrigersoft%2Fjaque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrigersoft%2Fjaque/lists"}