Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

AlhassanReda
Copy link

@AlhassanReda AlhassanReda commented Aug 19, 2018

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

AlhassanReda commented Aug 20, 2018

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

next time i will , i promise 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants