question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to compare a parameter type with a class

See original GitHub issue

Hi, I’ve been trying this in many ways but the API is very restrictive:

var paramInfo = methodInfo.getParameterInfo()[0];

if (paramInfo.getTypeDescriptor().equalsIgnoringTypeParams(/* ??? */)) { ... }

What to put in the question marks to know if a parameter is of a specific type?

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
xaviariascommented, Mar 3, 2019

Thanks so much @lukehutch, your documentation is very clear. As you said is more work, so for my use case I think is ok to loadClass, and also because is only done once.

1reaction
lukehutchcommented, Mar 1, 2019

I was looking for something more straight forward so I ended up loading the class and method to obtain the parameter types. With a good scanning filter, is not too bad to load some extra methods to filter by parameter type.

@xaviarias the loadClass() methods do not initialize the class when the class is loaded, so what you’re doing should be pretty fast. However check out the new documentation anyway (see previous comment), it is better to only load classes if you actually need them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java: Is it possible to compare a Class<?> object with a ...
Java: Is it possible to compare a Class<?> object with a generic type parameter? ... but how can i know if it represents...
Read more >
Comparer<T>.Compare(T, T) Method - Microsoft Learn
When overridden in a derived class, performs a comparison of two objects of the same type and returns a value indicating whether one...
Read more >
type() and isinstance() in Python with Examples - Guru99
Parameters. object: An object whose instance you are comparing with classtype. It will return true if the type matches otherwise false. class ......
Read more >
[class.compare.default]
A comparison operator function for class C that is defaulted on its first declaration and is not defined as deleted is implicitly defined...
Read more >
How to Compare Two Objects in Java - Javatpoint
In the Employee class, we have defined two fields regno of type int and name of type String. After that, we have created...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found