IntelliJ Community . AutoBoxingPlugin

 
AutoBoxingPlugin 

HOME INDEX SEARCH CHANGES GO  

AutoBoxingPlugin

Purpose

This plugin provides a number of intentions to wrap primitive types to their corresponding wrapper classes.

Description

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!

Plugins installation

  • Download the binary ZIP file (see below)
  • Copy autoboxing-xx.jar file in your IntelliJ/plugins directory.
  • Restart IntelliJ

History Log

Changes in 0.1.1

  • Fixed NPE.

Changes in 0.2

  • Added missing support for byte autoboxing.
  • Added intentions to convert string objects to primitive types.

Changes in 0.2.1

  • Fixed autoboxing for parameters to the constructor call.

Changes in 0.3.1

  • Added autoboxing of arrays to collections and vice versa.

Changes in 0.3.2

  • 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

Changes in 0.3.3

  • Fixed NPE

Changes in 0.4

  • Added unboxing of wrapper classes to primitive types.

Changes in 0.5

  • Added intentions to convert any object to string.
  • Bugfixes.

-- KeshSibilev - 27 May 2003

Changes in 0.5.1

  • Fixed problem when intentions were not available in context of return statement.

Changes in 0.5.2

  • Bugfixes.

Changes in 0.5.3

  • Fixed NPE.

Changes in 0.5.4

  • Changed the priority level of exceptions logging.

-- KeshSibilev - 28 May 2003

Changes in 0.5.5

  • Recompiled with build 818.

-- KeshSibilev - 30 May 2003

Changes in 0.6

  • 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

Changes in 0.7

  • 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

Changes in 0.7.1

  • 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

Changes in 0.8

  • Added new Converts an object to array of objects intention.

Changes in 0.8.1

  • 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;

Changes in 0.8.2

  • 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

Changes in 0.8.4

  • The plugin is recompiled for Aurora build #856 because of some Psi API changes.

-- KeshSibilev - 09 Jul 2003

IntelliJPluginWebForm
IntelliJPluginName: AutoBoxingPlugin
IntelliJPluginVersion: 0.8.5
IntelliJPluginVendor: Kesh Sibilev
IntelliJPluginBinary:
IntelliJPluginSource:
IntelliJPluginClassification: CodeHelper?, ProgramStructureInterface
TopicClassification: IntelliJPluginPackage
TopicShortDescription: Autoboxing intentions.
TestedOnOS: OsWinXP
ShouldRunOnOS: AnyOS

Attachment: sort Action: Size: Date: Who: Comment:
autoboxing_0.8.5.jar action 65075 24 Oct 2003 - 05:02 KeshSibilev ver 0.8.5
autobox_0.8.5.zip action 17254 24 Oct 2003 - 05:03 KeshSibilev ver 0.8.5

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.