Skip to content

Commit

Permalink
Make AbstractConfig collection fields explicity Immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaroclapp committed May 13, 2022
1 parent 4bd9e78 commit ad57184
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions nullaway/src/main/java/com/uber/nullaway/AbstractConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,25 @@ public abstract class AbstractConfig implements Config {

protected boolean handleTestAssertionLibraries;

protected Set<String> optionalClassPaths;
protected ImmutableSet<String> optionalClassPaths;

protected boolean assertsEnabled;

/**
* if true, {@link #fromAnnotatedPackage(Symbol.ClassSymbol)} will return false for any class
* annotated with {@link javax.annotation.Generated}
*/
protected boolean treatGeneratedAsUnannotated;

protected boolean acknowledgeAndroidRecent;

protected Set<MethodClassAndName> knownInitializers;
protected ImmutableSet<MethodClassAndName> knownInitializers;

protected Set<String> excludedClassAnnotations;
protected ImmutableSet<String> excludedClassAnnotations;

protected Set<String> generatedCodeAnnotations;
protected ImmutableSet<String> generatedCodeAnnotations;

protected Set<String> initializerAnnotations;
protected ImmutableSet<String> initializerAnnotations;

protected Set<String> externalInitAnnotations;
protected ImmutableSet<String> externalInitAnnotations;

protected Set<String> contractAnnotations;
protected ImmutableSet<String> contractAnnotations;

@Nullable protected String castToNonNullMethod;

Expand Down Expand Up @@ -193,12 +189,12 @@ public boolean isUnannotatedClass(Symbol.ClassSymbol symbol) {

@Override
public ImmutableSet<String> getExcludedClassAnnotations() {
return ImmutableSet.copyOf(excludedClassAnnotations);
return excludedClassAnnotations;
}

@Override
public ImmutableSet<String> getGeneratedCodeAnnotations() {
return ImmutableSet.copyOf(generatedCodeAnnotations);
return generatedCodeAnnotations;
}

@Override
Expand Down Expand Up @@ -262,7 +258,7 @@ public boolean handleTestAssertionLibraries() {
}

@Override
public Set<String> getOptionalClassPaths() {
public ImmutableSet<String> getOptionalClassPaths() {
return optionalClassPaths;
}

Expand Down Expand Up @@ -296,15 +292,15 @@ public boolean isContractAnnotation(String annotationName) {
return contractAnnotations.contains(annotationName);
}

protected Set<MethodClassAndName> getKnownInitializers(Set<String> qualifiedNames) {
protected ImmutableSet<MethodClassAndName> getKnownInitializers(Set<String> qualifiedNames) {
Set<MethodClassAndName> result = new LinkedHashSet<>();
for (String name : qualifiedNames) {
int lastDot = name.lastIndexOf('.');
String methodName = name.substring(lastDot + 1);
String className = name.substring(0, lastDot);
result.add(MethodClassAndName.create(className, methodName));
}
return result;
return ImmutableSet.copyOf(result);
}

@AutoValue
Expand Down

0 comments on commit ad57184

Please sign in to comment.