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.
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 |
---|---|---|
|
|
CAN NOT COMBINE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
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.
-
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 |
Note
|
Visibility of all accessors will be the one specified by the attribute of the |
-
Supplement an
equals
method. -
Supplement a
hashCode
method.
Caution
|
Transient fields are ignored from the |
-
Supplement constructors that takes arguments for initialize the fields.
-
Supplement
java.io.Serializable
to implemented interfaces. -
Supplement getters for fields defined the class.
-
Supplement an
equals
method. -
Supplement a
hashCode
method.
-
Supplement
final
modifier to the class. -
Supplement an uncallable constructor.
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. |
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.
See the develhacked-lombok-example project for more information.
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
|
|
Usage is basically the same as the original Lombok. However, you should add the Develhack Core Library to class-path.
<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>
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 ]
}
}
}
Download the develhacked-lombok-0.1.3.jar from the release page. Then execute it and follow the instructions.