{"id":13458763,"url":"https://github.com/jOOQ/jOOR","last_synced_at":"2025-03-24T15:32:00.811Z","repository":{"id":2126845,"uuid":"3069822","full_name":"jOOQ/jOOR","owner":"jOOQ","description":" jOOR - Fluent Reflection in Java jOOR is a very simple fluent API that gives access to your Java Class structures in a more intuitive way. The JDK's reflection APIs are hard and verbose to use. Other languages have much simpler constructs to access type meta information at runtime. Let us make Java reflection better.","archived":false,"fork":false,"pushed_at":"2025-01-06T10:12:58.000Z","size":515,"stargazers_count":2818,"open_issues_count":25,"forks_count":375,"subscribers_count":115,"default_branch":"main","last_synced_at":"2025-03-18T05:07:49.239Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.jooq.org/products","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/jOOQ.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-12-29T17:01:00.000Z","updated_at":"2025-03-15T09:59:40.000Z","dependencies_parsed_at":"2024-01-03T01:20:51.210Z","dependency_job_id":"7a09d9b7-a30a-471c-bba4-94c2fc3a2b89","html_url":"https://github.com/jOOQ/jOOR","commit_stats":{"total_commits":232,"total_committers":21,"mean_commits":"11.047619047619047","dds":0.1594827586206896,"last_synced_commit":"dac3f552b9ca46b1c697e9d759ff90d6a99e50ae"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jOOQ","download_url":"https://codeload.github.com/jOOQ/jOOR/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245298195,"owners_count":20592562,"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-07-31T09:00:56.987Z","updated_at":"2025-03-24T15:31:55.800Z","avatar_url":"https://github.com/jOOQ.png","language":"Java","readme":"### Overview\r\n\r\njOOR stands for jOOR Object Oriented Reflection. It is a simple wrapper for the java.lang.reflect package.\r\n\r\njOOR's name is inspired by jOOQ, a fluent API for SQL building and execution.\r\n\r\n\r\n### Dependencies\r\n\r\nNone!\r\n\r\n### Download\r\n\r\n**For use with Java 9+**\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003eorg.jooq\u003c/groupId\u003e\r\n  \u003cartifactId\u003ejoor\u003c/artifactId\u003e\r\n  \u003cversion\u003e0.9.15\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n**For use with Java 8+**\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003eorg.jooq\u003c/groupId\u003e\r\n  \u003cartifactId\u003ejoor-java-8\u003c/artifactId\u003e\r\n  \u003cversion\u003e0.9.15\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n**For use with Java 6+**\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003eorg.jooq\u003c/groupId\u003e\r\n  \u003cartifactId\u003ejoor-java-6\u003c/artifactId\u003e\r\n  \u003cversion\u003e0.9.15\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n### Simple example\r\n\r\n````java\r\n// All examples assume the following static import:\r\nimport static org.joor.Reflect.*;\r\n\r\nString world = onClass(\"java.lang.String\") // Like Class.forName()\r\n                .create(\"Hello World\")     // Call most specific matching constructor\r\n                .call(\"substring\", 6)      // Call most specific matching substring() method\r\n                .call(\"toString\")          // Call toString()\r\n                .get();                    // Get the wrapped object, in this case a String\r\n````\r\n\r\n\r\n### Proxy abstraction\r\n\r\njOOR also gives access to the java.lang.reflect.Proxy API in a simple way:\r\n\r\n````java\r\npublic interface StringProxy {\r\n  String substring(int beginIndex);\r\n}\r\n\r\nString substring = onClass(\"java.lang.String\")\r\n                    .create(\"Hello World\")\r\n                    .as(StringProxy.class) // Create a proxy for the wrapped object\r\n                    .substring(6);         // Call a proxy method\r\n````\r\n\r\n### Runtime compilation of Java code\r\n\r\njOOR has an optional dependency on the `java.compiler` module and simplifies access to `javax.tools.JavaCompiler` through the following API:\r\n\r\n```java\r\nSupplier\u003cString\u003e supplier = Reflect.compile(\r\n    \"com.example.HelloWorld\",\r\n    \"package com.example;\\n\" +\r\n    \"class HelloWorld implements java.util.function.Supplier\u003cString\u003e {\\n\" +\r\n    \"    public String get() {\\n\" +\r\n    \"        return \\\"Hello World!\\\";\\n\" +\r\n    \"    }\\n\" +\r\n    \"}\\n\").create().get();\r\n\r\n// Prints \"Hello World!\"\r\nSystem.out.println(supplier.get());\r\n```\r\n\r\n### Comparison with standard java.lang.reflect\r\n\r\njOOR code:\r\n\r\n````java\r\nEmployee[] employees = on(department).call(\"getEmployees\").get();\r\n\r\nfor (Employee employee : employees) {\r\n  Street street = on(employee).call(\"getAddress\").call(\"getStreet\").get();\r\n  System.out.println(street);\r\n}\r\n````\r\n\r\nThe same example with normal reflection in Java:\r\n\r\n````java\r\ntry {\r\n  Method m1 = department.getClass().getMethod(\"getEmployees\");\r\n  Employee[] employees = (Employee[]) m1.invoke(department);\r\n\r\n  for (Employee employee : employees) {\r\n    Method m2 = employee.getClass().getMethod(\"getAddress\");\r\n    Address address = (Address) m2.invoke(employee);\r\n\r\n    Method m3 = address.getClass().getMethod(\"getStreet\");\r\n    Street street = (Street) m3.invoke(address);\r\n\r\n    System.out.println(street);\r\n  }\r\n}\r\n\r\n// There are many checked exceptions that you are likely to ignore anyway \r\ncatch (Exception ignore) {\r\n\r\n  // ... or maybe just wrap in your preferred runtime exception:\r\n  throw new RuntimeException(e);\r\n}\r\n````\r\n\r\n\r\n### Similar projects\r\n\r\nEveryday Java reflection with a fluent interface:\r\n\r\n * http://docs.codehaus.org/display/FEST/Reflection+Module\r\n * http://projetos.vidageek.net/mirror/mirror/\r\n\r\nReflection modelled as XPath (quite interesting!)\r\n\r\n * http://commons.apache.org/jxpath/users-guide.html\r\n\r\n","funding_links":[],"categories":["Java","Projects","项目"],"sub_categories":["Introspection","内省"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjOOQ%2FjOOR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FjOOQ%2FjOOR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjOOQ%2FjOOR/lists"}