I am developing an API. It will have many methods that do the same, but have different parameter primitives.
public void someMethod1(int x);
public void someMethod1(float x);
public void someMethod1(double x);
public void someMethod2(int x, int y);
...
public void someMethod3(int x, int y, int z);
...
Because of the primitives, I have to copy and paste a lot, which, in my opinion, can not be controlled over time. Is it a good idea to avoid primitives in methods and constructors? For example, replacing the above would be:
public <T extends Number> void someMethod1(T x);
public <T extends Number> void someMethod2(T x, T y);
public <T extends Number> void someMethod3(T x, T y, T z);
Edit:
What are the disadvantages of this?
source
share