Skip to content

Commit 138c735

Browse files
committed
0.2.2
- Updated pom.xml - Improved JavaDocs - Added missing @nonnull annotations - Added deployment - Ran Intellij IDEA's reformat tool on everything - Added -Xlint:unchecked - Removed Jenkinsfile because I've given up on getting gpg code signing to work in Jenkins. Maybe revisit this in the future.
1 parent 075e0de commit 138c735

File tree

7 files changed

+2533
-2406
lines changed

7 files changed

+2533
-2406
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ target/
33
*.iml
44
.attach_pid*
55
.idea/
6-
*.versionsBackup
6+
*.versionsBackup
7+
*.backup

Jenkinsfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ So I decided to build a library to make things a bit easier for me.
1212
### Why not use `Objects.requireNonNull(T)`?
1313

1414
`Objects.requireNonNull(T)` will throw `NullPointerException` and I disagree with this choice of exception because `NullPointerException` is supposed to be thrown in event of null object being de-referenced. Like:
15+
1516
```
1617
StringBuilder sb = null;
1718
sb.append("something"); // <-- This will throw NullPointerException because you are trying to de-reference a null object
@@ -24,13 +25,24 @@ I think `IllegalArgumentException` is more appropriate exception to best describ
2425
## Prerequisites
2526

2627
* Java 8 or better
27-
* Maven
2828

2929
## Download
3030

31-
**No Maven Repository available yet ):**
31+
### Package Repository
32+
33+
The library is availble for download on Sonatype public Maven repository (https://oss.sonatype.org/#nexus):
34+
35+
```xml
36+
<dependency>
37+
<groupId>com.ansill.validation</groupId>
38+
<artifactId>validation</artifactId>
39+
<version>0.2.2</version>
40+
</dependency>
41+
```
3242

33-
For now, you need to build and install it on your machine.
43+
### Build
44+
45+
Maven (or other similar build tools) is needed to build and install JavaValidation.
3446

3547
```bash
3648
$ git clone https://github.com/tomansill/javavalidation
@@ -44,7 +56,7 @@ Then include the dependency in your project's `pom.xml`:
4456
<dependency>
4557
<groupId>com.ansill.validation</groupId>
4658
<artifactId>validation</artifactId>
47-
<version>0.1.0</version>
59+
<version>0.2.2</version>
4860
</dependency>
4961
```
5062

@@ -64,16 +76,16 @@ public class Application{
6476
application.print(message);
6577
}
6678
public void print(String message){
67-
Validation.assertNonnull(message);
68-
System.out.println(message);
79+
System.out.println(Validation.assertNonnull(message));
6980
}
7081
}
7182
```
7283

7384
When you run the code, it will yield this message:
85+
7486
```
7587
Exception in thread "main" java.lang.IllegalArgumentException: Value is expected to be non-null but is found to be null
76-
at Application.print(Application.java:10)
88+
at Application.print(Application.java:9)
7789
at Application.main(Application.java:7)
7890
```
7991

@@ -91,16 +103,16 @@ public class Application{
91103
}
92104
private int port = 80;
93105
public void setPort(int port){
94-
Validation.assertNaturalNumber(port, "port");
95-
this.port = port;
106+
this.port = Validation.assertNaturalNumber(port, "port");
96107
}
97108
}
98109
```
99110

100111
When you run the code, it will yield this message:
112+
101113
```
102114
Exception in thread "main" java.lang.IllegalArgumentException: Value in variable 'port' is expected to be a natural number (1, 2, ..., N-1, N) but it is actually not a natural number
103-
at Application.setPort(Application.java:10)
115+
at Application.setPort(Application.java:9)
104116
at Application.main(Application.java:6)
105117
```
106118

@@ -125,6 +137,7 @@ public class Application{
125137
```
126138

127139
When you run the code, it will yield this message:
140+
128141
```
129142
Exception in thread "main" java.lang.IllegalArgumentException: Value is expected to be non-negative but value is actually a negative number
130143
at Application.add(Application.java:10)
@@ -151,6 +164,7 @@ public class Application{
151164
```
152165

153166
When you run the code, it will yield this message:
167+
154168
```
155169
Exception in thread "main" java.lang.IllegalArgumentException: Value in variable 'name' is expected to be non-empty but value is actually a empty string
156170
at Application.<init>(Application.java:9)
@@ -179,6 +193,7 @@ public class Application{
179193
```
180194

181195
When you run the code, it will yield this message:
196+
182197
```
183198
Exception in thread "main" java.lang.IllegalArgumentException: Value is expected to be non-empty but value is actually empty
184199
at Application.<init>(Application.java:11)
@@ -207,6 +222,7 @@ public class Application{
207222
```
208223

209224
When you run the code, it will yield this message:
225+
210226
```
211227
Exception in thread "main" java.lang.IllegalArgumentException: Value is expected to have all of its list members to be non-null but the list contains null members. Invalid members are located at indices [1, 3, 4]
212228
at Application.<init>(Application.java:11)

pom.xml

Lines changed: 106 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,45 @@
66

77
<groupId>com.ansill.validation</groupId>
88
<artifactId>validation</artifactId>
9-
<version>0.2.1</version>
9+
<packaging>jar</packaging>
10+
<version>0.2.2</version>
1011
<!-- mvn versions:set -DnewVersion=your version -->
1112

12-
<packaging>jar</packaging>
13+
<name>${project.groupId}:${project.artifactId}</name>
14+
<description>A simple and easy-to-use validation utility library</description>
15+
<url>https://github.com/tomansill/JavaValidation</url>
16+
17+
<scm>
18+
<connection>scm:git:git://github.com/tomansill/JavaValidation.git</connection>
19+
<developerConnection>scm:git:ssh://github.com:tomansill/JavaValidation.git</developerConnection>
20+
<url>https://github.com/tomansill/JavaValidation/tree/master</url>
21+
</scm>
22+
23+
<licenses>
24+
<license>
25+
<name>MIT License</name>
26+
<url>https://github.com/tomansill/JavaValidation/blob/master/LICENSE</url>
27+
</license>
28+
</licenses>
29+
30+
<developers>
31+
<developer>
32+
<name>Tom Ansill</name>
33+
<email>tom@ansill.com</email>
34+
<organizationUrl>http://tom.ansill.com</organizationUrl>
35+
</developer>
36+
</developers>
37+
38+
<distributionManagement>
39+
<repository>
40+
<id>ossrh</id>
41+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
42+
</repository>
43+
<snapshotRepository>
44+
<id>ossrh</id>
45+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
46+
</snapshotRepository>
47+
</distributionManagement>
1348

1449
<build>
1550
<plugins>
@@ -18,6 +53,9 @@
1853
<artifactId>maven-compiler-plugin</artifactId>
1954
<version>3.8.0</version>
2055
<configuration>
56+
<compilerArguments>
57+
<compilerArgument>-Xlint:unchecked</compilerArgument>
58+
</compilerArguments>
2159
<source>8</source>
2260
<target>8</target>
2361
</configuration>
@@ -27,11 +65,73 @@
2765
<artifactId>maven-surefire-plugin</artifactId>
2866
<version>2.22.1</version>
2967
</plugin>
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-source-plugin</artifactId>
71+
<version>3.2.0</version>
72+
<executions>
73+
<execution>
74+
<id>attach-sources</id>
75+
<goals>
76+
<goal>jar-no-fork</goal>
77+
</goals>
78+
</execution>
79+
</executions>
80+
</plugin>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-javadoc-plugin</artifactId>
84+
<version>3.2.0</version>
85+
<configuration>
86+
<failOnError>true</failOnError>
87+
<failOnWarnings>true</failOnWarnings>
88+
</configuration>
89+
<executions>
90+
<execution>
91+
<id>attach-javadocs</id>
92+
<goals>
93+
<goal>jar</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-gpg-plugin</artifactId>
101+
<version>1.5</version>
102+
<executions>
103+
<execution>
104+
<id>sign-artifacts</id>
105+
<phase>deploy</phase>
106+
<goals>
107+
<goal>sign</goal>
108+
</goals>
109+
<configuration>
110+
<gpgArguments>
111+
<!-- Necessary to solve inappropriate ioctl error -->
112+
<arg>--pinentry-mode</arg>
113+
<arg>loopback</arg>
114+
</gpgArguments>
115+
</configuration>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
<plugin>
120+
<groupId>org.sonatype.plugins</groupId>
121+
<artifactId>nexus-staging-maven-plugin</artifactId>
122+
<version>1.6.7</version>
123+
<extensions>true</extensions>
124+
<configuration>
125+
<serverId>ossrh</serverId>
126+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
127+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
128+
</configuration>
129+
</plugin>
30130
</plugins>
31131
</build>
32132

33133
<properties>
34-
<junit.jupiter.version>5.4.2</junit.jupiter.version>
134+
<junit.jupiter.version>5.6.0</junit.jupiter.version>
35135
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36136
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
37137
</properties>
@@ -40,7 +140,7 @@
40140
<dependency>
41141
<groupId>com.google.code.findbugs</groupId>
42142
<artifactId>jsr305</artifactId>
43-
<version>3.0.0</version>
143+
<version>3.0.2</version>
44144
</dependency>
45145
<dependency>
46146
<groupId>org.junit.jupiter</groupId>
@@ -57,7 +157,7 @@
57157
<dependency>
58158
<groupId>org.junit.jupiter</groupId>
59159
<artifactId>junit-jupiter-params</artifactId>
60-
<version>5.4.2</version>
160+
<version>${junit.jupiter.version}</version>
61161
<scope>test</scope>
62162
</dependency>
63163
<dependency>
@@ -67,4 +167,4 @@
67167
<scope>test</scope>
68168
</dependency>
69169
</dependencies>
70-
</project>
170+
</project>

0 commit comments

Comments
 (0)