Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[not for review yet] deps: changing jsr305 to jspecify #3191

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
6 changes: 3 additions & 3 deletions api-common-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
<version>${auto-value.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

/** Abstract implementation of ApiFuture that mirrors {@code AbstractFuture} in Guava. */
public abstract class AbstractApiFuture<V> implements ApiFuture<V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

/** Static utility methods for the {@link ApiFuture} interface. */
public final class ApiFutures {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Represents a path template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Class for representing and working with resource names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class AnnotationNode implements AstNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class ClassDefinition implements AstNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class ConcreteReference implements Reference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class MethodDefinition implements AstNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class MethodInvocationExpr implements Expr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.google.common.collect.ImmutableList;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

public interface Reference extends AstNode {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class ThrowExpr implements Expr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class TryCatchStatement implements Statement {
Expand Down Expand Up @@ -60,7 +60,7 @@ public abstract static class Builder {

public abstract Builder setIsSampleCode(boolean isSampleCode);

public Builder addCatch(@Nonnull VariableExpr variableExpr, List<Statement> body) {
public Builder addCatch(@NonNull VariableExpr variableExpr, List<Statement> body) {
List<VariableExpr> catchVarExprs = new ArrayList<>(catchVariableExprs());
catchVarExprs.add(variableExpr);
setCatchVariableExprs(catchVarExprs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class TypeNode implements AstNode, Comparable<TypeNode> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class VaporReference implements Reference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class VariableExpr implements Expr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

public class ImportWriterVisitor implements AstNodeVisitor {
private static final String DOT = ".";
Expand All @@ -91,12 +91,12 @@ public void clear() {
importShortNames.clear();
}

public void initialize(@Nonnull String currentPackage) {
public void initialize(@NonNull String currentPackage) {
this.currentPackage = currentPackage;
currentClassName = null;
}

public void initialize(@Nonnull String currentPackage, @Nonnull String currentClassName) {
public void initialize(@NonNull String currentPackage, @NonNull String currentClassName) {
this.currentPackage = currentPackage;
this.currentClassName = currentClassName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;
import org.threeten.bp.Duration;

public abstract class AbstractServiceStubSettingsClassComposer implements ClassComposer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

public abstract class AbstractTransportServiceStubClassComposer implements ClassComposer {
private static final Statement EMPTY_LINE_STATEMENT = EmptyLineStatement.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.api.generator.gapic.model.Transport;
import com.google.auto.value.AutoValue;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class TransportContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.auto.value.AutoValue;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class GapicBatchingSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class GapicContext {
Expand Down Expand Up @@ -67,8 +67,7 @@ public GapicMetadata gapicMetadata() {
@Nullable
public abstract GapicServiceConfig serviceConfig();

@Nullable
public abstract com.google.api.Service serviceYamlProto();
public abstract com.google.api.@Nullable Service serviceYamlProto();

public boolean containsServices() {
return !services().isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class HttpBindings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.google.api.generator.engine.ast.TypeNode;
import com.google.auto.value.AutoValue;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class LongrunningOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class Message {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class Method {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class ResourceName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import java.util.List;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

@AutoValue
public abstract class Service {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
package com.google.api.generator.gapic.model;

import com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NonNull;

/**
* A light wrapper around SourceCodeInfo.Location to provide cleaner protobuf comments. Please see
* additional documentation on descriptor.proto.
*/
public class SourceCodeInfoLocation {
@Nonnull private final Location location;
@NonNull private final Location location;

private SourceCodeInfoLocation(Location location) {
this.location = location;
}

public static SourceCodeInfoLocation create(@Nonnull Location location) {
public static SourceCodeInfoLocation create(@NonNull Location location) {
return new SourceCodeInfoLocation(location);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

public class ResourceReferenceParser {
private static final String EMPTY_STRING = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.google.protobuf.Descriptors.OneofDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import java.util.Map;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;

/**
* A helper class which provides protocol buffer source info for descriptors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NonNull;

public class TypeParser {
private static Reference REFERENCE_BYTE_STRING = ConcreteReference.withClazz(ByteString.class);
Expand Down Expand Up @@ -62,7 +62,7 @@ public class TypeParser {
.put(JavaType.BYTE_STRING, REFERENCE_BYTE_STRING)
.build();

public static TypeNode parseType(@Nonnull FieldDescriptor field) {
public static TypeNode parseType(@NonNull FieldDescriptor field) {
if (field.isMapField()) {
return createMapType(field);
}
Expand All @@ -83,11 +83,11 @@ public static TypeNode parseType(@Nonnull FieldDescriptor field) {
return TypeNode.withReference(parseFieldReference(field));
}

public static TypeNode parseType(@Nonnull Descriptor messageDescriptor) {
public static TypeNode parseType(@NonNull Descriptor messageDescriptor) {
return TypeNode.withReference(parseMessageReference(messageDescriptor));
}

public static TypeNode parseType(@Nonnull EnumDescriptor enumDescriptor) {
public static TypeNode parseType(@NonNull EnumDescriptor enumDescriptor) {
return TypeNode.withReference(parseEnumReference(enumDescriptor));
}

Expand Down Expand Up @@ -119,7 +119,7 @@ static Reference parseFieldReference(FieldDescriptor field) {
}

@VisibleForTesting
static Reference parseMessageReference(@Nonnull Descriptor messageDescriptor) {
static Reference parseMessageReference(@NonNull Descriptor messageDescriptor) {
List<String> outerNestedTypeNames = new ArrayList<>();
FileOptions fileOptions = messageDescriptor.getFile().getOptions();
String javaOuterClassname =
Expand Down Expand Up @@ -179,7 +179,7 @@ static Reference parseMessageReference(@Nonnull Descriptor messageDescriptor) {
}

@VisibleForTesting
static Reference parseEnumReference(@Nonnull EnumDescriptor enumDescriptor) {
static Reference parseEnumReference(@NonNull EnumDescriptor enumDescriptor) {
// This is similar to parseMessageReference, but we make it a separate method because
// EnumDescriptor and Descriptor are sibling types.
FileOptions fileOptions = enumDescriptor.getFile().getOptions();
Expand Down
Loading
Loading