Skip to content

Commit

Permalink
Show processing error if multiple databases that have different rxJav…
Browse files Browse the repository at this point in the history
…aSupport setting are found
  • Loading branch information
k-kagurazaka committed Oct 30, 2018
1 parent 642d55a commit f7cd364
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.TypeName;

import androidx.annotation.Nullable;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Type;
Expand All @@ -47,6 +45,8 @@
import javax.lang.model.util.Types;
import javax.tools.Diagnostic;

import androidx.annotation.Nullable;

public class ProcessingContext {

public final ProcessingEnvironment processingEnv;
Expand Down Expand Up @@ -224,9 +224,27 @@ public boolean isRxJavaSupport(SchemaDefinition schema) {
if (databases.isEmpty()) {
return Database.DEFAULT_RX_JAVA_SUPPORT;
}
return databases

long targetCount = databases
.stream()
.filter((database) -> database.getSchemas().contains(schema))
.count();

long rxJavaSupportCount = databases
.stream()
.anyMatch((database) -> database.isRxJavaSupport() && database.getSchemas().contains(schema));
.filter((database) -> database.getSchemas().contains(schema) && database.isRxJavaSupport())
.count();

if (rxJavaSupportCount == 0L) {
return false;
}

if (rxJavaSupportCount < targetCount) {
addError(schema.getModelClassName().simpleName() + " is included in different RxJavaSupport databases.",
schema.getElement());
}

return true;
}

public void note(String message) {
Expand Down

0 comments on commit f7cd364

Please sign in to comment.