Skip to content

Commit

Permalink
Converted to Preconditions.checkNotNull.
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Jan 25, 2022
1 parent 750ff31 commit 255bc60
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static com.uber.nullaway.NullAway.getTreesInstance;

import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -518,12 +519,9 @@ public void serializeFixSuggestion(VisitorState state, Symbol target, ErrorMessa
FixLocation location = AbstractFixLocation.createFixLocationFromSymbol(target);
SuggestedFixInfo suggestedFixInfo = buildFixMetadata(state.getPath(), errorMessage, location);
Serializer serializer = serializationConfig.getSerializer();
if (serializer != null) {
serializer.serializeSuggestedFixInfo(suggestedFixInfo, serializationConfig.suggestEnclosing);
} else {
throw new IllegalStateException(
"Serializer shouldn't be null at this point, error in configuration setting!");
}
Preconditions.checkNotNull(
serializer, "Serializer shouldn't be null at this point, error in configuration setting!");
serializer.serializeSuggestedFixInfo(suggestedFixInfo, serializationConfig.suggestEnclosing);
}

/**
Expand All @@ -534,12 +532,9 @@ public void serializeFixSuggestion(VisitorState state, Symbol target, ErrorMessa
*/
public void serializeReportingError(VisitorState state, ErrorMessage errorMessage) {
Serializer serializer = config.getSerializationConfig().getSerializer();
if (serializer != null) {
serializer.serializeErrorInfo(new ErrorInfo(state.getPath(), errorMessage));
} else {
throw new IllegalStateException(
"Serializer shouldn't be null at this point, error in configuration setting!");
}
Preconditions.checkNotNull(
serializer, "Serializer shouldn't be null at this point, error in configuration setting!");
serializer.serializeErrorInfo(new ErrorInfo(state.getPath(), errorMessage));
}

/** Builds the {@link SuggestedFixInfo} instance based on the {@link ErrorMessage} type. */
Expand Down

0 comments on commit 255bc60

Please sign in to comment.