mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 16:20:34 +00:00
Change return type of Trip.products() from List to Set.
This commit is contained in:
parent
24e921e547
commit
5f8fc199a4
1 changed files with 5 additions and 12 deletions
|
@ -19,9 +19,10 @@ package de.schildbach.pte.dto;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
|
@ -186,22 +187,14 @@ public final class Trip implements Serializable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Product> products()
|
public Set<Product> products()
|
||||||
{
|
{
|
||||||
final List<Product> products = new LinkedList<Product>();
|
final Set<Product> products = EnumSet.noneOf(Product.class);
|
||||||
|
|
||||||
if (legs != null)
|
if (legs != null)
|
||||||
{
|
|
||||||
for (final Leg leg : legs)
|
for (final Leg leg : legs)
|
||||||
{
|
|
||||||
if (leg instanceof Public)
|
if (leg instanceof Public)
|
||||||
{
|
products.add(Product.fromCode(((Public) leg).line.label.charAt(0)));
|
||||||
final Product product = Product.fromCode(((Public) leg).line.label.charAt(0));
|
|
||||||
if (!products.contains(product))
|
|
||||||
products.add(product);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue