Skip to content

Commit

Permalink
Remove usage of @nonnull annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed Oct 8, 2024
1 parent b60f98f commit 162d9d3
Show file tree
Hide file tree
Showing 228 changed files with 201 additions and 744 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -57,7 +56,6 @@ void instanceId(FareProduct fareProduct, ZonedDateTime startTime, String expecte
assertEquals(expectedInstanceId, instanceId);
}

@Nonnull
private static FareProduct fareProduct(Duration duration, RiderCategory cat, FareMedium medium) {
return new FareProduct(
new FeedScopedId("fares", "daypass"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -216,7 +215,6 @@ private Itinerary getItinerary(GenericLocation from, GenericLocation to, int ind
return itineraries.get(index);
}

@Nonnull
private static List<Itinerary> getItineraries(
GenericLocation from,
GenericLocation to,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.annotation.Nonnull;
import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.i18n.NonLocalizedString;
import org.opentripplanner.framework.i18n.TranslatedString;
Expand Down Expand Up @@ -114,7 +113,6 @@ public void realtimeStation() {
assertEquals(3, map.get("spacesAvailable"));
}

@Nonnull
private static RentalVehicleType vehicleType(RentalFormFactor formFactor) {
return new RentalVehicleType(
new FeedScopedId("1", formFactor.name()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.io.IOException;
import java.net.URI;
import java.util.Collections;
import javax.annotation.Nonnull;
import org.opentripplanner.datastore.api.CompositeDataSource;
import org.opentripplanner.datastore.api.DataSource;
import org.opentripplanner.datastore.api.FileType;
Expand Down Expand Up @@ -39,7 +38,7 @@ public void open() {
}

@Override
public DataSource findSource(@Nonnull URI uri, @Nonnull FileType type) {
public DataSource findSource(URI uri, FileType type) {
if (skipUri(uri)) {
return null;
}
Expand All @@ -48,7 +47,7 @@ public DataSource findSource(@Nonnull URI uri, @Nonnull FileType type) {
}

@Override
public CompositeDataSource findCompositeSource(@Nonnull URI uri, @Nonnull FileType type) {
public CompositeDataSource findCompositeSource(URI uri, FileType type) {
if (skipUri(uri)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.model.fare.FareProductUse;
Expand Down Expand Up @@ -39,19 +38,16 @@ public Agency getAgency() {
return first.getAgency();
}

@Nonnull
@Override
public TransitMode getMode() {
return first.getMode();
}

@Nonnull
@Override
public Route getRoute() {
return first.getRoute();
}

@Nonnull
@Override
public Trip getTrip() {
return first.getTrip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opentripplanner.ext.fares.model.FareDistance;
import org.opentripplanner.ext.fares.model.FareLegRule;
import org.opentripplanner.ext.fares.model.FareTransferRule;
Expand Down Expand Up @@ -210,7 +209,7 @@ private boolean transferRuleMatchesNextLeg(
.orElse(false);
}

private Optional<FareLegRule> getFareLegRuleByGroupId(@Nonnull FeedScopedId groupId) {
private Optional<FareLegRule> getFareLegRuleByGroupId(FeedScopedId groupId) {
return legRules.stream().filter(lr -> groupId.equals(lr.legGroupId())).findAny();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package org.opentripplanner.ext.fares.model;

import java.util.Objects;
import javax.annotation.Nonnull;
import org.opentripplanner.transit.model.basic.Money;
import org.opentripplanner.transit.model.framework.AbstractTransitEntity;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand Down Expand Up @@ -77,7 +76,7 @@ public Integer getJourneyDuration() {
}

@Override
public boolean sameAs(@Nonnull FareAttribute other) {
public boolean sameAs(FareAttribute other) {
return (
getId().equals(other.getId()) &&
getPrice().equals(other.getPrice()) &&
Expand All @@ -88,7 +87,6 @@ public boolean sameAs(@Nonnull FareAttribute other) {
);
}

@Nonnull
@Override
public FareAttributeBuilder copy() {
return new FareAttributeBuilder(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opentripplanner.model.fare.FareProduct;
import org.opentripplanner.transit.model.framework.FeedScopedId;

public record FareLegRule(
@Nonnull FeedScopedId id,
FeedScopedId id,
@Nullable FeedScopedId legGroupId,
@Nullable String networkId,
@Nullable String fromAreaId,
@Nullable String toAreaId,
@Nullable FareDistance fareDistance,
@Nonnull Collection<FareProduct> fareProducts
Collection<FareProduct> fareProducts
) {
public FareLegRule {
Objects.requireNonNull(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import java.time.Duration;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opentripplanner.model.fare.FareProduct;
import org.opentripplanner.transit.model.framework.FeedScopedId;

public record FareTransferRule(
@Nonnull FeedScopedId id,
FeedScopedId id,
@Nullable FeedScopedId fromLegGroup,
@Nullable FeedScopedId toLegGroup,
int transferCount,
@Nullable Duration timeLimit,
@Nonnull Collection<FareProduct> fareProducts
Collection<FareProduct> fareProducts
) {
public String feedId() {
return id.getFeedId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.common.collect.ImmutableMultimap;
import jakarta.inject.Inject;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import org.locationtech.jts.geom.Point;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.framework.logging.ProgressTracker;
Expand Down Expand Up @@ -77,7 +76,6 @@ public void buildGraph() {
LOG.info(progress.completeMessage());
}

@Nonnull
private static Stream<MatchResult> matchingVerticesForStop(
StreetIndex streetIndex,
AreaStop areaStop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.ext.flex.edgetype.FlexTripEdge;
import org.opentripplanner.framework.i18n.I18NString;
Expand Down Expand Up @@ -96,7 +95,6 @@ public LegTime end() {
}

@Override
@Nonnull
public TransitMode getMode() {
return getTrip().getMode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.time.LocalDate;
import java.util.Objects;
import javax.annotation.Nonnull;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPath;
import org.opentripplanner.ext.flex.trip.FlexTrip;
Expand Down Expand Up @@ -92,7 +91,6 @@ public double getDistanceMeters() {
}

@Override
@Nonnull
public State[] traverse(State s0) {
StateEditor editor = s0.edit(this);
editor.setBackMode(TraverseMode.FLEX);
Expand Down
3 changes: 1 addition & 2 deletions src/ext/java/org/opentripplanner/ext/flex/trip/FlexTrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPathCalculator;
import org.opentripplanner.model.PickDrop;
import org.opentripplanner.model.StopTime;
Expand Down Expand Up @@ -140,7 +139,7 @@ public abstract FlexPathCalculator decorateFlexPathCalculator(
);

@Override
public boolean sameAs(@Nonnull T other) {
public boolean sameAs(T other) {
return getId().equals(other.getId()) && Objects.equals(trip, other.getTrip());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPathCalculator;
import org.opentripplanner.ext.flex.flexpathcalculator.ScheduledFlexPathCalculator;
import org.opentripplanner.model.PickDrop;
Expand Down Expand Up @@ -152,7 +151,7 @@ public boolean isAlightingPossible(StopLocation toStop) {
}

@Override
public boolean sameAs(@Nonnull ScheduledDeviatedTrip other) {
public boolean sameAs(ScheduledDeviatedTrip other) {
return (
super.sameAs(other) &&
Arrays.equals(stopTimes, other.stopTimes) &&
Expand All @@ -161,7 +160,6 @@ public boolean sameAs(@Nonnull ScheduledDeviatedTrip other) {
);
}

@Nonnull
@Override
public TransitBuilder<ScheduledDeviatedTrip, ScheduledDeviatedTripBuilder> copy() {
return new ScheduledDeviatedTripBuilder(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPathCalculator;
import org.opentripplanner.ext.flex.flexpathcalculator.TimePenaltyCalculator;
import org.opentripplanner.framework.lang.DoubleUtils;
Expand Down Expand Up @@ -197,7 +196,7 @@ public boolean isAlightingPossible(StopLocation stop) {
}

@Override
public boolean sameAs(@Nonnull UnscheduledTrip other) {
public boolean sameAs(UnscheduledTrip other) {
return (
super.sameAs(other) &&
Arrays.equals(stopTimes, other.stopTimes) &&
Expand All @@ -206,7 +205,6 @@ public boolean sameAs(@Nonnull UnscheduledTrip other) {
);
}

@Nonnull
@Override
public TransitBuilder<UnscheduledTrip, UnscheduledTripBuilder> copy() {
return new UnscheduledTripBuilder(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.time.Duration;
import java.time.Instant;
import java.util.function.Supplier;
import javax.annotation.Nonnull;

/**
* The purpose of this class is to be a generic container for caching expensive computations.
Expand All @@ -16,7 +15,7 @@ public class CachedValue<T> {
private T value;
private Instant timeout;

public CachedValue(@Nonnull Duration cacheInterval) {
public CachedValue(Duration cacheInterval) {
this.value = null;
this.cacheInterval = cacheInterval;
this.timeout = calculateTimeout();
Expand All @@ -27,7 +26,7 @@ public CachedValue(@Nonnull Duration cacheInterval) {
* <p>
* Otherwise, recompute and return it.
*/
public T get(@Nonnull Supplier<T> supplier) {
public T get(Supplier<T> supplier) {
synchronized (this) {
if (hasExpired()) {
this.value = supplier.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nonnull;
import org.opentripplanner.standalone.api.OtpServerRequestContext;

public class GraphReportBuilder {
Expand Down Expand Up @@ -50,13 +49,11 @@ public static GraphStats build(OtpServerRequestContext context) {
);
}

@Nonnull
private static String firstLetterToLowerCase(Object instance) {
var className = instance.getClass().getSimpleName();
return Character.toLowerCase(className.charAt(0)) + className.substring(1);
}

@Nonnull
private static <T> TypeStats countValues(Collection<T> input, Function<T, String> classify) {
Map<String, Integer> result = new HashMap<>();
input.forEach(item -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.opentripplanner.framework.geometry.SphericalDistanceLibrary;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.I18NString;
Expand Down Expand Up @@ -196,7 +195,6 @@ private TxPoint pointInfo(TransferPoint p, boolean boarding) {
return r;
}

@Nonnull
private static String getName(Operator operator) {
return Optional.ofNullable(operator).map(o -> o.getId().getId()).orElse("");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.opentripplanner.ext.ridehailing.model;

import javax.annotation.Nonnull;
import org.opentripplanner.model.plan.StreetLeg;
import org.opentripplanner.model.plan.StreetLegBuilder;

Expand All @@ -27,7 +26,6 @@ public RideHailingProvider provider() {
return provider;
}

@Nonnull
public RideEstimate rideEstimate() {
return estimate;
}
Expand Down
Loading

0 comments on commit 162d9d3

Please sign in to comment.