Closed oxplay2 closed 3 years ago
also added
public <T> T getAttribute(String key, Class<T> castClass);
into interface to allow more clean casting way. If you have something against it, please tell.
I just got back home, I will review today. Thank you for the addition.
I think this is great the way it is, but I have two items to run by you prior to merging in.
First, the JME engine uses set/getUserData
, perhaps we can rename attributes to user data to be more consistent with the engine? While the outside engine uses the term attributes so that is where that came from, I think it would be best for this library to maintain consistency with jme.
Second, jme uses a bound generic type on the <T>getUserData()
function where they do not pass in the class type.
node.setUserData("hi", 7);
int i = node.<Integer>getUserData("hi");
System.out.println(i);
While I generally prefer how you have it now, where the class type is passed in as an argument, for the sake of consistancy with the engine, should we make function a generic function without the type as a parameter? This would be as simple as removing the Class<T> castClass
from the parameters of the function.
good catch, the class param was used for generic type, so its generally same, but i forgot that no need second method here as no need provide T and it will just return Object. So changed to single method solution.
changed name to getUserData
Looks good, thank you!