Skip to content

Commit

Permalink
Merge pull request eugenp#8919 from eugenp/BAEL-3461-v2
Browse files Browse the repository at this point in the history
move nullaway article
  • Loading branch information
lor6 authored Mar 20, 2020
2 parents 31d88cb + 522a62b commit 5f9a566
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 60 deletions.
2 changes: 2 additions & 0 deletions libraries-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

56 changes: 56 additions & 0 deletions libraries-3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@
<artifactId>velocity-engine-core</artifactId>
<version>${velocity-engine-core.version}</version>
</dependency>
<dependency>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>0.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8</version>
</dependency>
<!-- override plexus-compiler-javac-errorprone's dependency on
Error Prone with the latest version -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>

<repositories>
Expand Down Expand Up @@ -130,6 +147,45 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<annotationProcessorPaths>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>0.3.0</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<!-- NullAway will warn by default, uncomment the next line to make the build fail -->
<!-- <arg>-Xep:NullAway:ERROR</arg> -->
<arg>-XepExcludedPaths:(.*)/test/.*|(.*)/jcabi/.*</arg>
<arg>-XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway</arg>
</compilerArgs>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8</version>
</dependency>
<!-- override plexus-compiler-javac-errorprone's dependency on
Error Prone with the latest version -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.3.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.baeldung.nullaway;

import com.baeldung.distinct.Person;

public class NullAwayExample {

/*
Expand Down
65 changes: 65 additions & 0 deletions libraries-3/src/main/java/com/baeldung/nullaway/Person.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
1 change: 0 additions & 1 deletion libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
57 changes: 0 additions & 57 deletions libraries/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -435,23 +435,6 @@
<artifactId>reflections</artifactId>
<version>${reflections.version}</version>
</dependency>
<dependency>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>0.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8</version>
</dependency>
<!-- override plexus-compiler-javac-errorprone's dependency on
Error Prone with the latest version -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>

<repositories>
Expand Down Expand Up @@ -569,46 +552,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<annotationProcessorPaths>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>0.3.0</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<!-- NullAway will warn by default, uncomment the next line to make the build fail -->
<!-- <arg>-Xep:NullAway:ERROR</arg> -->
<arg>-XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.*</arg>
<arg>-XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway</arg>
</compilerArgs>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8</version>
</dependency>
<!-- override plexus-compiler-javac-errorprone's dependency on
Error Prone with the latest version -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
</plugin>

</plugins>
</build>

Expand Down

0 comments on commit 5f9a566

Please sign in to comment.