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
Returns data type name (string) for getTypeStr() in FieldInfo class #140
Comments
However, just adding |
Oh, it gets worse than that: If the type of the field is say What you probably need to do is just load the class whose fields you want to probe, and then use regular reflection to test if the fields have the properties you want. The correct way to load classes given a Does that work for you? |
okay . Got it will try it out. I am working on speed test to compare between reflection and your library for a project in my company. If your lib is efficient we would migrate to it. So please do consider this as request and implement these in future. Thank you . |
@febielgiva based on a great suggestion by @Alexander--, the exact method you were looking for is now supported: |
@febielgiva Added a unit test that seems to indicate this should be working for you too now, so I'll close this. Please still comment if you do test this, to let me know how it goes for you. I'll also release a new version now. Thanks for this report! |
PS please also let me know what your benchmark scores were for the two libraries, I'm interested in real-world numbers. Thanks. |
sure I will let know once I tested it . Thank you for implementing those. its would be really useful. Do you have any method similar to invoke() method in reflect and a method to get just the constructor of a class? . Thank you . |
You can't invoke a method in this way, because the class hasn't even been loaded (assuming other code hasn't already loaded the calss) -- that's the whole point of The constructors are called |
I went ahead and made these changes:
|
(PS although I closed this, I'm still interested in benchmarks, whenever you have a chance to report on that -- no rush, and thanks!) |
Released in 2.7.0. |
for a object of FieldInfo the getTypeStr() return the field's data type example "Integer/String/int" but I need to check whether the data type is valid or not .
I need to pass the data type's class to the below function
public static boolean isValidType(Class<?> retType) { if (retType.isPrimitive() && retType != void.class) return true; if (Number.class.isAssignableFrom(retType)) return true; if (AbstractCode.class.isAssignableFrom(retType)) return true; if (Boolean.class == retType) return true; if (Character.class == retType) return true; if (String.class == retType) return true; if (Date.class.isAssignableFrom(retType)) return true; if (byte[].class.isAssignableFrom(retType)) return true; if (Enum.class.isAssignableFrom(retType)) return true; return false; }
But what i have is data type name ( string) which is useless . You should store the class type of the data type like the REFLECT Field variables.
The text was updated successfully, but these errors were encountered: