{"id":19177002,"url":"https://github.com/joomcode/grip","last_synced_at":"2025-04-20T02:35:03.001Z","repository":{"id":43277689,"uuid":"412782399","full_name":"joomcode/grip","owner":"joomcode","description":"SQL-like queries on JVM classes metadata using Kotlin DSL","archived":false,"fork":false,"pushed_at":"2022-08-16T16:11:26.000Z","size":632,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2024-04-24T08:24:09.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/joomcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-02T11:55:17.000Z","updated_at":"2024-04-02T22:57:46.000Z","dependencies_parsed_at":"2022-08-30T09:11:26.771Z","dependency_job_id":null,"html_url":"https://github.com/joomcode/grip","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomcode%2Fgrip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomcode%2Fgrip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomcode%2Fgrip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomcode%2Fgrip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joomcode","download_url":"https://codeload.github.com/joomcode/grip/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223816658,"owners_count":17207897,"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":[],"created_at":"2024-11-09T10:31:34.370Z","updated_at":"2024-11-09T10:31:49.529Z","avatar_url":"https://github.com/joomcode.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://github.com/joomcode/grip/actions/workflows/build.yml/badge.svg)](https://github.com/joomcode/grip/actions/workflows/build.yml)\n\nGrip\n====\n\nSQL-like queries on JVM classes metadata using Kotlin DSL.\n\nDownload\n--------\nGradle:\n```groovy\nrepositories {\n  mavenCentral()\n}\n\ndependencies {\n  compile 'com.joom.grip:grip:0.8.0'\n}\n```\n\nUsage\n-----\nBefore executing any queries you need to create an instance of `Grip` interface.\n```kotlin\nval grip = GripFactory.create(classpath)\n```\n\nNow you can query classes from a `.jar` file, or `classes` directory, or just a single `.class`\nfile that satisfy some condition. For example that's how you can find all `public` classes in a\n`.jar` file.\n```kotlin\nval query = grip select classes from file where isPublic()\n```\nIf you don't like the DSL syntax it's possible to use traditional method chaining.\n```kotlin\nval query = grip\n    .select(classes)\n    .from(file)\n    .where(isPublic())\n```\nThe query is a lazy object. It must be executed explicitly to return results. After the first\nexecution **results are cached**.\n```kotlin\nval classes = query.execute()\n```\nThe `classes` variable contains a map from `Type` to `ClassMirror`. `ClassMirror` is an\nobject representation of class metadata. It provides functionality similar to `java.lang.Class`.\nThere're other *mirror* classes such as `MethodMirror`, `FieldMirror`, `AnnotationMirror` and more.\n\nQuery conditions can be much more complicated than just `isPublic()`. You can combine multiple\nconditions with `and`, `or,` `xor` and `not`. That's how you can query all non-`final` classes\nthat implement `java.util.List`.\n```kotlin\nval query = grip select classes from file where\n    (not(isFinal()) and interfacesContain(getType\u003cList\u003c*\u003e\u003e()))\n```\nMoreover, you can query methods or fields that satisfy some conditions. Here's how you can find\nall deprecated methods from all classes.\n```kotlin\nval query = grip select methods from file where annotatedWith(getType\u003cDeprecated\u003e())\n```\nAnd finally, subqueries are supported. For example, you can queries `public` non-`final` fields\nfrom `public` classes.\n```kotlin\nval subquery = grip select classes from file where isPublic()\nval query = grip select fields from subquery where (isPublic() and not(isFinal()))\n```\n\nThere're more conditions available, which you can find [here][1]. But if you need a condition\nthat's not present in the project you can add a new condition to your own project easily and use\nit in queries.\n\nLicense\n=======\n    Copyright 2022 SIA Joom\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n [1]: https://github.com/joomcode/grip/blob/master/library/src/main/kotlin/io/joomcode/grip/Matchers.kt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomcode%2Fgrip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoomcode%2Fgrip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomcode%2Fgrip/lists"}