From f3d7a9d5febfe9c5aab4f6e7558ada74bce9a4a3 Mon Sep 17 00:00:00 2001 From: Loredana Date: Thu, 19 Mar 2020 22:38:01 +0200 Subject: [PATCH] move nullaway article --- libraries-3/README.md | 2 + libraries-3/pom.xml | 56 ++++++++++++++++ .../baeldung/nullaway/NullAwayExample.java | 2 - .../java/com/baeldung/nullaway/Person.java | 65 +++++++++++++++++++ libraries/README.md | 1 - libraries/pom.xml | 57 ---------------- 6 files changed, 123 insertions(+), 60 deletions(-) rename {libraries => libraries-3}/src/main/java/com/baeldung/nullaway/NullAwayExample.java (93%) create mode 100644 libraries-3/src/main/java/com/baeldung/nullaway/Person.java diff --git a/libraries-3/README.md b/libraries-3/README.md index 0a76c7ff6e..f3c3375098 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -14,3 +14,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to cache2k](https://www.baeldung.com/java-cache2k) - [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects) - [Introduction to Takes](https://www.baeldung.com/java-takes) +- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) + diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index 68b5f2aa21..4b9cac8cff 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -94,6 +94,23 @@ velocity-engine-core ${velocity-engine-core.version} + + com.uber.nullaway + nullaway + 0.3.0 + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.8 + + + + com.google.errorprone + error_prone_core + 2.1.3 + @@ -130,6 +147,45 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.5 + + javac-with-errorprone + true + 1.8 + 1.8 + true + + + com.uber.nullaway + nullaway + 0.3.0 + + + + + + -XepExcludedPaths:(.*)/test/.*|(.*)/jcabi/.* + -XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway + + + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.8 + + + + com.google.errorprone + error_prone_core + 2.3.4 + + + diff --git a/libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java b/libraries-3/src/main/java/com/baeldung/nullaway/NullAwayExample.java similarity index 93% rename from libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java rename to libraries-3/src/main/java/com/baeldung/nullaway/NullAwayExample.java index f3db1d2df9..1fab591cb0 100644 --- a/libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java +++ b/libraries-3/src/main/java/com/baeldung/nullaway/NullAwayExample.java @@ -1,7 +1,5 @@ package com.baeldung.nullaway; -import com.baeldung.distinct.Person; - public class NullAwayExample { /* diff --git a/libraries-3/src/main/java/com/baeldung/nullaway/Person.java b/libraries-3/src/main/java/com/baeldung/nullaway/Person.java new file mode 100644 index 0000000000..fcd88036a1 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/nullaway/Person.java @@ -0,0 +1,65 @@ +package com.baeldung.nullaway; + +public class Person { + int age; + String name; + String email; + + public Person(int age, String name, String email) { + super(); + this.age = age; + this.name = name; + this.email = email; + } + + public int getAge() { + return age; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Person [age="); + builder.append(age); + builder.append(", name="); + builder.append(name); + builder.append(", email="); + builder.append(email); + builder.append("]"); + return builder.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((email == null) ? 0 : email.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Person other = (Person) obj; + if (email == null) { + if (other.email != null) + return false; + } else if (!email.equals(other.email)) + return false; + return true; + } + +} diff --git a/libraries/README.md b/libraries/README.md index f439033730..79ba8fe55d 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -45,5 +45,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) -- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - More articles [[next -->]](/libraries-2) diff --git a/libraries/pom.xml b/libraries/pom.xml index af300657b0..41bc2b9311 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -435,23 +435,6 @@ reflections ${reflections.version} - - com.uber.nullaway - nullaway - 0.3.0 - - - org.codehaus.plexus - plexus-compiler-javac-errorprone - 2.8 - - - - com.google.errorprone - error_prone_core - 2.1.3 - @@ -569,46 +552,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.5 - - javac-with-errorprone - true - 1.8 - 1.8 - true - - - com.uber.nullaway - nullaway - 0.3.0 - - - - - - -XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.* - -XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway - - - - - org.codehaus.plexus - plexus-compiler-javac-errorprone - 2.8 - - - - com.google.errorprone - error_prone_core - 2.1.3 - - - -