Skip to content

Commit 1e38b14

Browse files
Add Javadoc
1 parent df8b11d commit 1e38b14

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

src/ext/java/org/opentripplanner/ext/fares/model/FareProductInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* An instance of a fare product that might be shared across several legs.
5-
*
5+
* <p>
66
* The instance id identifies the fare product across the legs.
77
*/
88
public record FareProductInstance(String instanceId, FareProduct product) {}

src/main/java/org/opentripplanner/model/plan/Itinerary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ public int getLegIndex(Leg leg) {
540540
}
541541

542542
/**
543-
* The cost of this trip
543+
* The fare products of this itinerary.
544544
*/
545545
public ItineraryFares getFares() {
546546
return fare;
@@ -553,8 +553,8 @@ public void setFare(ItineraryFares fare) {
553553
.getItineraryProducts()
554554
.stream()
555555
.map(fp -> {
556-
var id = fp.uniqueInstanceId(firstLeg().getStartTime());
557-
return new FareProductInstance(id, fp);
556+
var instanceId = fp.uniqueInstanceId(firstLeg().getStartTime());
557+
return new FareProductInstance(instanceId, fp);
558558
})
559559
.toList();
560560

src/main/java/org/opentripplanner/routing/core/ItineraryFares.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public Multimap<Leg, FareProductInstance> getLegProducts() {
7777
return ImmutableMultimap.copyOf(legProducts);
7878
}
7979

80+
/**
81+
* Add a "fare". This is an ill-defined concept (is it for the entire itinerary or only some
82+
* legs?) from the early days of OTP which will be removed in the future.
83+
* <p>
84+
* Use {@link ItineraryFares#addFareProduct(Leg, FareProduct)},
85+
* {@link ItineraryFares#addLegProducts(Collection)} or
86+
* {@link ItineraryFares#addItineraryProducts(Collection)} instead.
87+
*/
88+
@Deprecated
8089
public void addFare(FareType fareType, Money money) {
8190
itineraryProducts.add(
8291
new FareProduct(
@@ -90,6 +99,14 @@ public void addFare(FareType fareType, Money money) {
9099
);
91100
}
92101

102+
/**
103+
* Add a collection of "fare components" for a type. These concepts are ill-defined and will be
104+
* removed in the future.
105+
* <p>
106+
* Use @{link {@link ItineraryFares#addItineraryProducts(Collection)}},
107+
* {@link ItineraryFares#addFareProduct(Leg, FareProduct)} or
108+
* {@link ItineraryFares#addLegProducts(Collection)} instead.
109+
*/
93110
@Deprecated
94111
public void addFareComponent(FareType fareType, List<FareComponent> components) {
95112
this.components.replaceValues(fareType, components);
@@ -120,6 +137,14 @@ public void addItineraryProducts(Collection<FareProduct> products) {
120137
itineraryProducts.addAll(products);
121138
}
122139

140+
/**
141+
* Get the "fare" for a specific fare type.
142+
* <p>
143+
* It is ill-defined what this actually means (entire itinerary?, some legs?).
144+
* <p>
145+
* Use {@link ItineraryFares#getItineraryProducts()} or {@link ItineraryFares#getLegProducts()}
146+
* instead.
147+
*/
123148
public Money getFare(FareType type) {
124149
return itineraryProducts
125150
.stream()
@@ -129,10 +154,21 @@ public Money getFare(FareType type) {
129154
.orElse(null);
130155
}
131156

157+
/**
158+
* Get the "components" of a fare for a specific type.
159+
* <p>
160+
* Use {@link ItineraryFares#getItineraryProducts()} or {@link ItineraryFares#getLegProducts()}
161+
* instead.
162+
*/
163+
@Deprecated
132164
public List<FareComponent> getComponents(FareType type) {
133165
return List.copyOf(components.get(type));
134166
}
135167

168+
/**
169+
* Return the set of {@link FareType}s that are contained in this instance.
170+
*/
171+
@Deprecated
136172
public Set<FareType> getFaresV1Types() {
137173
return itineraryProducts
138174
.stream()
@@ -144,7 +180,7 @@ public Set<FareType> getFaresV1Types() {
144180

145181
@Override
146182
public int hashCode() {
147-
return Objects.hash(itineraryProducts, legProducts);
183+
return Objects.hash(itineraryProducts, legProducts, components);
148184
}
149185

150186
@Override
@@ -167,6 +203,9 @@ public String toString() {
167203
.toString();
168204
}
169205

206+
/**
207+
* Add a complex set of fare products for a specific leg;
208+
*/
170209
public void addLegProducts(Collection<LegProducts> legProducts) {
171210
legProducts.forEach(lp -> {
172211
var time = lp.leg().getStartTime();
@@ -180,6 +219,9 @@ public void addLegProducts(Collection<LegProducts> legProducts) {
180219
});
181220
}
182221

222+
/**
223+
* Add a single fare product for a single leg.
224+
*/
183225
public void addFareProduct(Leg leg, FareProduct fareProduct) {
184226
this.legProducts.put(
185227
leg,

0 commit comments

Comments
 (0)