mbien opened a new pull request #3240:
URL: https://github.com/apache/netbeans/pull/3240
* repurpose a dusty perf rule to suggest `Boxed.valueOf() ->
Boxed.parseType()` refactoring where applicable
* extract some functionality into a new rule which has the lone purpose to
get rid of deprecated boxed primitive construction
example:
```java
private static void a(Integer i) {}
private static void b(String foo, int i) {}
private static void c(String foo, double a, long i) {}
public static void test() {
a(Integer.valueOf("")); // should do nothing, since destination
type is not primitive
b("abcd", Integer.valueOf("1")); // -> parseInt
b("abcd", Integer.valueOf(1)); // -> parseInt
c("asdf", Float.valueOf("1"), Long.valueOf("1")); // -> parseFloat,
parseLong
float five1 = Float.valueOf("5"); // -> parseFloat
Object five2 = Float.valueOf("5"); // does nothing
new ArrayList<>(Integer.valueOf("6")); // constructors work too
if(5 < Integer.valueOf("6").intValue()) {} // -> remove .intValue()
-> parseInt
....
}
```
todo
* tests not updated
* getDestinationType() might not cover enough cases
* would be a great utility method if made accessible from hint files ;)
* I don't actually know what I am doing, feedback appreciated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists