I don\'t really understand how the class
keywords work in some instances.
For example, the get(ClientResponse.class)
method takes the Cl
A class is a "blueprint" of the object. The instance is a object.
If we have
public class SomeClass {
int a;
SomeClass(int a) {
this.a = a
}
}
We can have an instance of this class
SomeClass c = new SomeClass(10);
c
is an instance of the class. It has a integer a
with value 10
.
The object SomeClass.class
represents a Class
.
Here SomeClass.class
is a object
of the type Class
which has the information that SomeClass
is
with a integer member variable
and lots more other metadata
about the class SomeClass
. Note that it does not have a value for a
.
You should use get(c)
incase you are planning to do something with a instance
of c
like call c.a
or other useful functions to manupulate/get data of the instance.
You should use get(SomeClass.class)
when the get returns something based on the fact that the argument is some type of class. For example, if this is a method on a Registry
class which has a map which retrieves a implementation class
based on type of class passed in.