jOOQ / jOOR

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.
http://www.jooq.org/products
Apache License 2.0
2.81k stars 376 forks source link

first version of wrapped by String path . easy way to get / set Object #63

Closed AlhassanReda closed 6 years ago

AlhassanReda commented 6 years ago

hi i added full new branch of wrapped object by String path . for ex : if i have object from a class i and i need array first index value b/arr/[0] this will send to me value

class a {
      b  b; 
    class b {
            String[] arr = {"some value"};
      }
}

not only that i make some observer list so any one can re call same path with different object very fast

lukaseder commented 6 years ago

Thank you very much for your suggestion.

I much prefer discussing the design of an idea first before looking into actual code, which is why I have rejected your pull request.

I understand you're thinking of implementing some expression language that abstracts over individual method calls. The specific use case you would like to see covered is accessing array elements by index, even in nested paths.

However, I'm pretty sure your current design and solution are lacking tons of things. I don't think we should rush such a big feature into jOOR. Besides, there are good expression language libraries in existence already, including Spring, so why not use that, instead? https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#expressions

AlhassanReda commented 6 years ago

spring it's not relative at all . the idea is get the wrapped object using path . A/A/getMethod() not just that it's fastest 10 times when you call back by observer list .

you didn't even check the code . i know my english is suck but try to look at the code and you will see

lukaseder commented 6 years ago

you didn't even check the code .

Yes, that's what I said. I said "I much prefer discussing the design of an idea first before looking into actual code"

Another important thing I said was: "However, I'm pretty sure your current design and solution are lacking tons of things. I don't think we should rush such a big feature into jOOR"

I'm sorry, I really cannot currently consider your PR, without a thorough discussion about the vision and design of such a feature set.

AlhassanReda commented 6 years ago

the idea is very simple this is jOOR code:

Employee[] employees = on(department).call("getEmployees").get();

for (Employee employee : employees) {
  Street street = on(employee).call("getAddress").call("getStreet").get();
  System.out.println(street);
}

My Implement :

Employee[] employees = ReflectFactory.getObject("getEmloyees()" ,department );

for (Employee employee : employees) {
  Street street =  ReflectFactory.getObject("getAddress()/getStreet()" ,employee);
  System.out.println(street);
}

not just that you can call

 Street street =  ReflectFactory.getObject("getEmloyees()/[0]/getAddress()/getStreet()" ,department );

will return the first employee

lukaseder commented 6 years ago

Thank you for following up. I understand your general idea, I just don't think this is well thought through. There are tons of open questions, which I currently would not really like to address. First off, why invent an own "mini language", rather than just supporting standard Java EL?

Please do accept my rejection of this idea for the moment.

AlhassanReda commented 6 years ago

amazing view 👍 i was going to use JXPATH in my project but it didn't support get public field direct . so i created this . but any way you are 100% right , and i will think again before i started any features . thank you again for your time , and have a good time .

lukaseder commented 6 years ago

Hah :-) In my opinion, it would be much easier to extend JXPath to do some additional reflection magic, rather than re-implementing JXPath in this little reflection library called jOOR. Which again underlines my reservation...

AlhassanReda commented 6 years ago

next time i will , i promise 💯