develhacked-lombok

The library enhancing Java classes at compilation by annotations that contained in the Develhack Core Library.

License

License

Categories

Categories

Lombok Application Layer Libs Code Generators
GroupId

GroupId

com.develhack
ArtifactId

ArtifactId

develhacked-lombok
Last Version

Last Version

0.1.5
Release Date

Release Date

Type

Type

jar
Description

Description

develhacked-lombok
The library enhancing Java classes at compilation by annotations that contained in the Develhack Core Library.
Project URL

Project URL

https://github.com/develhack/develhacked-lombok
Source Code Management

Source Code Management

https://github.com/develhack/develhacked-lombok.git

Download develhacked-lombok

How to add to project

<!-- https://jarcasting.com/artifacts/com.develhack/develhacked-lombok/ -->
<dependency>
    <groupId>com.develhack</groupId>
    <artifactId>develhacked-lombok</artifactId>
    <version>0.1.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.develhack/develhacked-lombok/
implementation 'com.develhack:develhacked-lombok:0.1.5'
// https://jarcasting.com/artifacts/com.develhack/develhacked-lombok/
implementation ("com.develhack:develhacked-lombok:0.1.5")
'com.develhack:develhacked-lombok:jar:0.1.5'
<dependency org="com.develhack" name="develhacked-lombok" rev="0.1.5">
  <artifact name="develhacked-lombok" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.develhack', module='develhacked-lombok', version='0.1.5')
)
libraryDependencies += "com.develhack" % "develhacked-lombok" % "0.1.5"
[com.develhack/develhacked-lombok "0.1.5"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Develhacked-Lombok

About

A library enhancing Java classes at compilation by annotations that contained in the Develhack Core Library. It’s powered by The Project Lombok.

This library provides following features.

Description

Injects argument check statements

If an argument is annotated, injects argument check statements as the first statement of a method or constructor.
Also, some annotations can combine with @Nullable for ignoring the check when the argument is null.

All statements generated by this feature are using the method prefixed by check that defined in the com.develhack.Conditions.
Correspondence between annotations and used method are below.

Annotation Used method Used method if combile with @Nullable

@Nonnull

checkNonnull

CAN NOT COMBINE

@Nonempty

checkNonempty

checkNonemptyIfNonnull

@Nonzero

checkNonzero

checkNonzeroIfNonnull

@Positive

checkPositive

checkPositiveIfNonnull

@Negative

checkNegative

checkNegativeIfNonnull

@ValidNumber

checkValidNumber

checkValidNumberIfNonnull

@FiniteNumber

checkFiniteNumber

checkFiniteNumberIfNonnull

@GreaterThan

checkGreaterThan

checkGreaterThanIfNonnull

@GreaterThanOrEqualTo

checkGreaterThanOrEqualTo

checkGreaterThanOrEqualToIfNonnull

@LessThan

checkLessThan

checkLessThanIfNonnull

@LessThanOrEqualTo

checkLessThanOrEqualTo

checkLessThanOrEqualToIfNonnull

@InRange

checkInRange

checkInRangeIfNonnull

Some annotations that having attributes of the comparison value, support the following types.

  • All primitive types

  • All wrapper of primitive types

  • java.math.BigInteger

  • java.math.BigDecimal

  • java.util.Date

  • Some types included java.time package

  • Some types included org.threeten.bp package of ThreeTen-Backport

Also, it accepts the following formats according to the type.

Number literal

A string representing a number literal. e.g. "1", "-1" and "1.0F".

Date time literal for java.util.Date

A string representing the date and time by such format as ISO 8601.
However, delimiters can not be omitted, and time zone can not be specified.
For example, "2015-01-01" or "2015-01-01T00:00:00".

Date time literal for java.time.* and org.threeten.bp.*

A string representing the date and time that parsable by the parse method defined on the type.

Variable reference

A string representing the variable reference.

Modifies a structure of the class to match the features

If a class or a field is annotated, modifies a structure of the class to match the features.

Correspondence between annotations and contents of modification are below.

@DTO (Applicable to classes)

  • Supplement java.io.Serializable to implemented interfaces.

  • Supplement accessors for fields defined the class.

Caution

Accessors of the transient field are not supplied by the annotation for the class. If necessary, please specify the @Accessible to the transient field individually.

Note

Visibility of all accessors will be the one specified by the attribute of the @DTO. If you want to specify a separate visibility, please specify the the @Accessible to individual fields for overridden the visibility.

@Equatable (Applicable to a class)

  • Supplement an equals method.

  • Supplement a hashCode method.

Caution

Transient fields are ignored from the equals method and hashCode method.

@Stringable (Applicable to classes)

  • Supplement a toString method.

@InitializeFieldsByConstructor (Applicable to a class)

  • Supplement constructors that takes arguments for initialize the fields.

@Serializable (Applicable to classes)

  • Supplement java.io.Serializable to implemented interfaces.

@VO (Applicable to classes)

  • Supplement java.io.Serializable to implemented interfaces.

  • Supplement getters for fields defined the class.

  • Supplement an equals method.

  • Supplement a hashCode method.

@Utility (Applicable to classes)

  • Supplement final modifier to the class.

  • Supplement an uncallable constructor.

@Accessible (Applicable to fields)

  • Supplement accessors for the field.

@ExcludedFrom (Applicable to fields)

  • Excludes the field from specified fietures.

Combination of the above

If specify the annotation that supplements the accessor for the field, and specify the annotation that represents assertion to the field together, the check argument statement is injected to the accessor.

Note

The check argument statement is injected to only the methods that is supplemented by this library.
The methods implemented by you are not injected the check argument statement.

A few configurable items

This library supports following configuration items that provided by the original Lombok. See the document of Lombok for information of those.

  • config.stopBubbling

  • lombok.addGeneratedAnnotation

  • lombok.extern.findbugs.addSuppressFBWarnings

  • lombok.accessors.prefix

Also, this library supports a few additional configuration items for Javadoc.
All of the following entry’s value will be formatted by the java.text.MessageFormat.

com.develhack.lombok.feature.getterCommentTemplate

If this entry is specified, a description of Javadoc comment to the getters that supplemented by this library will be generated.
The following parameters are specified at the time of format.

Index Value

0

A property name. e.g. a "foo" if the spplemented getter signature is getFoo().

1

A description of the field that is specified as the Javadoc comment to the field.

2 and subsequent

Attributes of @Meta if it is specified to the field.

com.develhack.lombok.feature.setterCommentTemplate

If this entry is specified, a description of Javadoc comment to the setters that supplemented by this library will be generated.
The following parameters are specified at the time of format.

Index Value

0

A property name. e.g. a "foo" if the spplemented setter signature is setFoo(Object foo).

1

A description of the field that is specified as the Javadoc comment to the field.

2 and subsequent

Attributes of @Meta if it is specified to the field.

com.develhack.lombok.feature.constructorCommentTemplate

If this entry is specified, Javadoc comment to the constructor that supplemented by this library will be generated.
The following parameters are specified at the time of format.

Index Value

0

The class name.

1

A description of the class that is specified as the Javadoc comment to the class.

2 and subsequent

Attributes of @Meta if it is specified to the class.

More information

See the develhacked-lombok-example project for more information.

Compatibility with the original Lombok

This library can coexist with the original Lombok, but can not be combine with the original Lombok.

For example, the argument check statement by the com.develhack.annotation.assertion.Nonempty is not injected to the method that will supplemented by the lombok.Setter.

Caution

@Nonnull and @Nullable will evaluated by some methods that supplemented by the original Lombok, because the original Lombok is detecting those annotations by the simple name.

Requirement

  • JDK 1.6 or higher

Usage

Usage is basically the same as the original Lombok. However, you should add the Develhack Core Library to class-path.

Maven

pom.xml
<dependency>
    <groupId>com.develhack</groupId>
    <artifactId>develhack-core</artifactId>
    <version>[0.9,1.0)</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>com.develhack</groupId>
    <artifactId>develhacked-lombok</artifactId>
    <version>0.1.3</version>
    <scope>provided</scope>
</dependency>

Gradle

build.gradle
configurations {
    apt {
            visible false
    }
}

dependencies {
    compile 'com.develhack:develhack-core:0.9.+'
    apt 'com.develhack:develhacked-lombok:0.1.3'
}

sourceSets {
    main {
        java {
            compileClasspath += [ configurations.apt ]
        }
    }
    test {
        java {
            compileClasspath += [ configurations.apt ]
        }
    }
}

Eclipse IDE

Download the develhacked-lombok-0.1.3.jar from the release page. Then execute it and follow the instructions.

License

com.develhack

Develhack

Versions

Version
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0