Documentation
This page is under construction. Please come back for more information.
For a list of short video tutorials, you can click here .
Create Similar class
This may be the most useful feature of this plugin. With this you can create similar classes, from FooDAO to FooService and FooService to FooAction. To use this feature you need to configure it by going to Windows -> Preference ->Fast Code Preference. Here is a screenshot. As one can see the it starts with a "From Classes" box. It is of the form (${ANY_PACKAGE}).dao.(${ANY_CLASS})DAO. Who is familar with regular expressions in java will have no problem to see the structure. It has been grouped using parenthesis. These groups can be used in the later parts of the configuration, especially "To Classes" field. Here you can use place holders e.g. ${1}, ${2} . It is to be noted that ${ANY_PACKAGE} and ${ANY_CLASS} are kind of reserved expressions, the '$' in ${ANY_PACKAGE} does not have the usual meaning of regular expression.
Typically, one would start from a DAO interface, e.g FooDAO. From this interface, you can create FooService and its implemenation FooServiceImpl . Then you can create configuration files as well. Certain types configurations come out of the box. Theses are spring, dozer, tiles, struts, etc. If you do not need these or need some other kind of configurations, you can open the jar file and edit the file org/fastcode/util/fast-code-config.xml. To any developer format of the file should be self explanatory. It is important to note that more than one configuration files can be created. This is especially useful for resource bundle typically required in web applications using struts or similar frameworks.
When you create a similar class, you can also copy all the public methods. It is recommended that you start with FooDAO interface, then create FooService & FooServiceImpl with this plugin and also create FooAction along with the configuration files.
One can copy the methods from the source class to the destination class. One can put some filters on the name of the methods to be copied. One can also copy one method only. To do this, one has to open the source class in editor, highlight any method name and right click and click Fast Code --> Create Similar Class in the popup menu. The plugin will copy only the method highlighted.
The create similar class can be used for value beans as well. In this case, 'Copy Fields' checkbox need to be checked.
In summary, plugin helps create similar class as shown in the following diagram :
-
com.abc.dao.FooDAO (Assume one already has this)
-
com.abc.dao.impl.FooDAOImpl (Assume one already has this)
-
com.abc.service.FooService (Can be created this with the plugin )
-
com.abc.service.impl.FooServiceImpl (Can be created this with the plugin )
-
com.abc.ui.action.FooAction ( Can be created this with the plugin )
-
com.abc.domain.FooPOJO (Assume you already have this)
-
com.abc.service.domain.FooVO ( Can be created with the plugin )
-
com.abc.ui.bean.domain.FooBean ( Can be created with the plugin )
-
Various configuration file skeleton (struts-config.xml, dozer-mapping.xml, Application.properties, etc) ( Can be created with the plugin )
One useful feature of the plugin is 'Create Similar Class with Different Name'. This is particularly useful to create similar classes in the same type, i.e. one DAO to another DAO or one service to another service. With this action one can create FooDAO to BarDAO with click of a mouse. As usual, if the FooDAO is an interface, you can create BarDAO interface along with the implementation class. You can copy the methods as well, but this time with a catch, method names are converted, e.g methods with name getFoo, saveFoo etc will be converted to getBar, saveBar etc.
JUMPing between Similar classES
An useful feature of this plugin is the ability to jump between similar class, e.g FooDAO to FooService, FooService to FooAction, etc. To use this feature, one needs to configure this first. To configure, please go to Windows -> Preferences ->Fast Code Preferences -> Mapping Btween Similar Classes. This is very similar to the configuration for create similar classes.
Dependency injection
Another useful feature of this plugin is easy dependency injection. Let us say one has class SampleServiceImpl which needs to have FooDao and BarDao as dependencies. Instead of manually creating an instance of the Dao classes and their getter/setters with their configurations, this plugin has feature that enables one to select FooDao and BarDao in the package explorer and click Fast Code -> Add As Spring Dependency. In one click it will create instances of FooDao and BarDao with the imports and the getter/setters. It will also update the configuration file. It is also possible to just create the instances without configuration. To do this just click Fast Code -> Create Dependency. This helps when one is using the spring's auto-inject feature or is not using the spring framework at all. With this plugin one can create simple (without configuration) of complex dependency injection of any number classes in one click.
Copy MEMber
With this plugin, one can create copies of members (fields/methods) in a class or interface. This come very convenient in large class. Let's say you want to create from field fooName to fooType and fooAge. To do this you select fooName and right click on it and navigate to Fast Code -> Copy Member menu. A simple dialog box will appear to prompt you to input. Here you just type Type and Age. You will see two new fields with name fooType and fooAge will be created. If the original field (fooName) had getter/setters the new fields will be created with getter/setters as well. If the original field had only getter or setter the new fields will also have only getter or setter. However, in the preferences, one can set the preference to always create getter/setters regardless whether the original fields has it or not, but it is not recommended. Similarly one can create copies of methods as well. One can, of course, select the full name of the field/method.
create list/map etc
This plugin helps create code snippet to create List/Map etc. This is especially useful for parameterized list. E.g, we want to create a List of class Foo as :
-
List<Foo> fooList = new ArrayList<Foo>();
As one can see there is so much typing involved although any ide's code assists feature help. With this plugin one can generate the whole line with one click along with all the necessary imports.
create import
Another useful feature of this plugin is to create import. Normally, one would not need to have another method to import files as eclipse already provides importing functionality. This plugin helps to create static import easily. If the class to be imported has static members only it can automatically create static import. As always, this feature is configurable.