Quantcast
Channel: Eclipse Plugins, Bundles and Products - Eclipse Marketplace | Eclipse Foundation - Explore, share, and collaborate on Eclipse Plugins, Tools, and Extensions. Discover new and popular additions to enhance your Eclipse development experience.
Viewing all articles
Browse latest Browse all 15920

SparkBuilderGenerator

$
0
0
Date Created: 
Sun, 2016-10-23 07:09
Date Updated: 
Mon, 2017-07-03 08:53

Generates a builder according to the GoF pattern for Java domain objects.

Features

  • Generates a builder with custom name patterns
  • Can generate staged builder
  • Capable of regenerating the builder
  • Compatible with most version of Eclipse
  • Highly configurable, check the plugin's preferences page
  • Capable of generate builder methods for visible fields in superclass
  • Open source (with very permissible MIT license)

Usage

To invoke the generation have a Java file active and press either the icon on the toolbar (the hammer) or Ctrl+Shift+B.
You can click the small arrow next to the main icon to generate a different builder type (like staged builder), if you usually generate a certain kind of builder, set the default builder in the preferences page.
You can set the preferences under: Window->Preferences->Java->Spark Builder Generator

Example result:

  public class Clazz {
        private Integer firstField;
        private Long secondField;
        @Generated("SparkTools")
        private Clazz(Builder builder) {
            this.firstField = builder.firstField;
            this.secondField = builder.secondField;
        }
        /**
         * Creates builder to build {@link Clazz}.
         * @return created builder
         */
        @Generated("SparkTools")
        public static Builder builder() {
            return new Builder();
        }
        /**
         * Builder to build {@link Clazz}.
         */
        @Generated("SparkTools")
        public static class Builder {
            private Integer firstField;
            private Long secondField;

            private Builder() {
            }

            /**
            * Builder method for firstField parameter.
            * @return builder
            */
            @Nonnull
            public Builder withFirstField(@Nonnull Integer firstField) {
                this.firstField = firstField;
                return this;
            }

            /**
            * Builder method for secondField parameter.
            * @return builder
            */
            @Nonnull
            public Builder withSecondField(@Nonnull Long secondField) {
                this.secondField = secondField;
                return this;
            }

            /**
            * Builder method of the builder.
            * @return built class
            */
            @Nonnull
            public Clazz build() {
                return new Clazz(this);
            }
        }
    }

Release notes

0.0.5 Added handling for code style prefix and suffix, see Github issue 5

0.0.6 Added staged builder support., see Github issue 4 Staged builder allows you to verify that all of the mandatory fields are set at compile time.

0.0.7 Option to add visible fields from superclasses to the builder, see Github issue 7

0.0.8 Fixed regression bug that was introduced in 0.0.7. While collection visible fields from superclasses, under some Eclipse configurations IllegalArgumentException occurred during java.lang.Object parsing.

0.0.9 Added option to generate builder to selected class (in case of nested classes, or multiple classes in a single file), see Github issue 10 Improvements to previous Builder class removing logic

0.0.10 Added the option to select which fields are generated in the builder, see Github issue 8
Fixed a small bug that deleted the previous builder when pressing the cancel button on the staging builder generator dialog Added MIT license file to plugin's site.xml, so it will show up on installation

Troubleshooting installation failure

Here are some common reasons installation fails, and steps to resolve

sun.security.validator.ValidatorException: PKIX path building failed

This happens, because your Java is unable to verify the certificate used by the update site. The update site uses valid certificate from Let's Encrypt, older Java (before 1.8.101) does not contain this root certificate. This together with some firewall settings can cause this error.
See this article: https://dzone.com/articles/eclipse-plug-ins-via-https-amp-lets-encrypt
Possible way to fix:

  • Update Java version to at lest 1.8.101
  • Import Let's Encrypt root certificate manually (refer to above article)
  • Use my FTP download site (See below)

Connection timeout

This is a temporary problem, while accessing the update site. The server most of the times will be available again in a couple of minutes.

  • You may try the FTP download site (see below)

For any other failure please contact me in the comments or Github.

Installing via FTP update site

In your Eclipse go to:

Help->Install new software->Copy and paste the following URI:

ftp://helospark.com:21/eclipse_plugin/SparkBuilderGeneratorPlugin/
(alternatively if port 21 is blocked, use port 799)
Select the latest version (should be under SparkTools category) and install.

Additional information:

On the GitHub page: https://github.com/helospark/SparkBuilderGenerator


Viewing all articles
Browse latest Browse all 15920

Trending Articles