This plugin provides a number of intentions to wrap primitive types to their corresponding wrapper classes.
Converts primitive types to their wrapper classes depending on the current context. For example,
- Integer integer = 10; => Integer integer = new Integer(10);
- integer = i + 2; => integer = new Integer(i + 2);
- Long longer = 100000l; => Long longer = new Long(100000l);
- Double aDouble = Math.PI/2; => Double aDouble = new Double(Math.PI/2);
- aList.add(34); => aList.add(new Integer(34));
- new Integer[] { 10 }; => new Integer[] { new Integer(10) };
- Boolean aBoolean = true; => Boolean aBoolean = Boolean .TRUE;
Converts wrapper classes to primitive types. For example,
- int i = anInteger; => int i = anInteger.intValue();
- boolean bool = aBoolean; => boolean bool = aBoolean.booleanValue();
- short sh = aDouble; => short sh = aDouble.shortValue();
- int i = anObject; => int i = ((Number)anObject).intValue();
- anArray[anInteger] => anArray[anInteger.intValue()]
- new int[] { anInteger }; => new Integer[] { anInteger.intValue() };
Converts string objects to wrapper classes. For example,
- Integer integer = "rere"; => Integer integer = Integer.valueOf("rere");
- Boolean aBoolean = "true"; => Boolean aBoolean = Boolean.valueOf("true");
Converts string objects to primitive types. For example,
- long aLong = "3423"; => long aLong = Long.parseLong("3423");
- boolean bool = "true"; => boolean bool = Boolean.valueOf("true").booleanValue();
Converts any object or primitive type to string. For example,
- String s = object; => String s = String.valueOf(object);
- String s = 10; => String s = String.valueOf(10);
Converts collection to array and vice versa. For example,
- Integer[] integers = collection; => Integer[] integers = (Integer[])collection.toArray(new Integer[collection.size()]);
- Collection collection = new Integer[12]; => Collection collection = Arrays.asList(new Integer[12]);
Converts an object to array of objects. For example,
- Integer[] integers = anInteger; => Integer[] integers = new Integer[] { anInteger };
IMPORTANT: this plugin will work only with Aurora build 816 or higher!
- Download the binary ZIP file (see below)
- Copy autoboxing-xx.jar file in your IntelliJ/plugins directory.
- Restart IntelliJ
- Added missing support for byte autoboxing.
- Added intentions to convert string objects to primitive types.
- Fixed autoboxing for parameters to the constructor call.
- Added autoboxing of arrays to collections and vice versa.
- New generated code is formatted according to the current code style.
- When converting array to collection the import java.util.Arrays statement is appended automatically to the import list.
-- KeshSibilev - 25 May 2003
- Added unboxing of wrapper classes to primitive types.
- Added intentions to convert any object to string.
- Bugfixes.
-- KeshSibilev - 27 May 2003
- Fixed problem when intentions were not available in context of return statement.
- Changed the priority level of exceptions logging.
-- KeshSibilev - 28 May 2003
- Recompiled with build 818.
-- KeshSibilev - 30 May 2003
- An intention is available if expected type is Object, but the actual expression has a primitive type. For example, aList.add(34); => aList.add(new Integer(34));
-- KeshSibilev - 02 Jun 2003
- Intentions are available in array initializer expressions.
- Converts wrapper classes to primitive types intention is extended to do an appropriate cast. For example, int i = anObject; => int i = ((Integer)anObject).intValue();
- Intentions are available in some binary expressions like <, >, !=. For example, if(i < "12") => if(i < Integer.parse("12"))
-- KeshSibilev - 19 Jun 2003
- Converts wrapper classes to primitive types intention performs cast to java.lang.Numeric type. For example, int i = anObject => int i = ((Numeric)anObject).intValue(). Thanks to Mario Ivankovits for pointing this out.
-- KeshSibilev - 20 Jun 2003
- Added new Converts an object to array of objects intention.
- When converting boolean constant to java.lang.Boolean class, an appropriate static fields of Boolean class are used. For example, Boolean aBoolean = true; => Boolean aBoolean = Boolean .TRUE;
- FIX: Boolean.valueOf method is used only when the project's JDK has version 1.4.x. Otherwise, Boolean constructor is used.
-- KeshSibilev - 25 Jun 2003
- The plugin is recompiled for Aurora build #856 because of some Psi API changes.
-- KeshSibilev - 09 Jul 2003
|
|