If possible, use generic type inference for constructing objects.

This commit is contained in:
Andreas Schildbach 2017-01-28 12:16:49 +01:00
parent dabbfc878b
commit bf510b516d
33 changed files with 128 additions and 128 deletions

View file

@ -256,7 +256,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
try {
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
final JSONObject stopFinder = head.optJSONObject("stopFinder");
@ -358,7 +358,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
protected SuggestLocationsResult xmlStopfinderRequest(final Location constraint) throws IOException {
final HttpUrl.Builder url = stopFinderEndpoint.newBuilder();
appendStopfinderRequestParameters(url, constraint, "XML");
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<SuggestLocationsResult>();
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -368,7 +368,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
pp.setInput(body.byteStream(), null); // Read encoding from XML declaration
final ResultHeader header = enterItdRequest(pp);
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
XmlPullUtil.enter(pp, "itdStopFinderRequest");
@ -400,7 +400,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
protected SuggestLocationsResult mobileStopfinderRequest(final Location constraint) throws IOException {
final HttpUrl.Builder url = stopFinderEndpoint.newBuilder();
appendStopfinderRequestParameters(url, constraint, "XML");
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<SuggestLocationsResult>();
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -410,7 +410,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
pp.setInput(body.byteStream(), null); // Read encoding from XML declaration
final ResultHeader header = enterEfa(pp);
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
XmlPullUtil.require(pp, "sf");
if (!pp.isEmptyElementTag()) {
@ -510,7 +510,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final int maxDistance, final int maxStations) throws IOException {
final HttpUrl.Builder url = coordEndpoint.newBuilder();
appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations);
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<NearbyLocationsResult>();
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -527,7 +527,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "coordInfoRequest");
XmlPullUtil.skipExit(pp, "coordInfoRequest");
final List<Location> locations = new ArrayList<Location>();
final List<Location> locations = new ArrayList<>();
if (XmlPullUtil.test(pp, "coordInfoItemList")) {
XmlPullUtil.enter(pp, "coordInfoItemList");
@ -584,7 +584,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final int maxDistance, final int maxStations) throws IOException {
final HttpUrl.Builder url = coordEndpoint.newBuilder();
appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations);
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<NearbyLocationsResult>();
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -599,7 +599,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "request");
XmlPullUtil.skipExit(pp, "request");
final List<Location> stations = new ArrayList<Location>();
final List<Location> stations = new ArrayList<>();
if (XmlPullUtil.test(pp, "pis")) {
XmlPullUtil.enter(pp, "pis");
@ -861,7 +861,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
url.addEncodedQueryParameter("mergeDep", "1");
url.addEncodedQueryParameter("useAllStops", "1");
url.addEncodedQueryParameter("mode", "direct");
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<NearbyLocationsResult>();
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -873,8 +873,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
final AtomicReference<Location> ownStation = new AtomicReference<Location>();
final List<Location> stations = new ArrayList<Location>();
final AtomicReference<Location> ownStation = new AtomicReference<>();
final List<Location> stations = new ArrayList<>();
final String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback() {
@Override
@ -1454,7 +1454,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final int maxDepartures, final boolean equivs) throws IOException {
final HttpUrl.Builder url = departureMonitorEndpoint.newBuilder();
appendXsltDepartureMonitorRequestParameters(url, stationId, time, maxDepartures, equivs);
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<QueryDeparturesResult>();
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -1628,7 +1628,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final int maxDepartures, final boolean equivs) throws IOException {
final HttpUrl.Builder url = departureMonitorEndpoint.newBuilder();
appendXsltDepartureMonitorRequestParameters(url, stationId, time, maxDepartures, equivs);
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<QueryDeparturesResult>();
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -2058,7 +2058,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final HttpUrl.Builder url = tripEndpoint.newBuilder();
appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
options);
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -2089,7 +2089,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final HttpUrl.Builder url = tripEndpoint.newBuilder();
appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
options);
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -2119,7 +2119,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final HttpUrl commandUrl = HttpUrl.parse(context.context);
final HttpUrl.Builder url = commandUrl.newBuilder();
url.addEncodedQueryParameter("command", later ? "tripNext" : "tripPrev");
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -2145,7 +2145,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final HttpUrl commandUrl = HttpUrl.parse(context.context);
final HttpUrl.Builder url = commandUrl.newBuilder();
url.addEncodedQueryParameter("command", later ? "tripNext" : "tripPrev");
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -2191,7 +2191,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
while (XmlPullUtil.test(pp, "itdOdv")) {
final String usage = XmlPullUtil.attr(pp, "usage");
final List<Location> locations = new ArrayList<Location>();
final List<Location> locations = new ArrayList<>();
final String nameState = processItdOdv(pp, usage, new ProcessItdOdvCallback() {
@Override
public void location(final String nameState, final Location location, final int matchQuality) {
@ -2256,7 +2256,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.requireSkip(pp, "itdTripOptions");
XmlPullUtil.optSkipMultiple(pp, "omcTaxi");
final List<Trip> trips = new ArrayList<Trip>();
final List<Trip> trips = new ArrayList<>();
XmlPullUtil.require(pp, "itdItinerary");
if (!pp.isEmptyElementTag()) {
@ -2288,7 +2288,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.optSkip(pp, "itdMapItemList");
XmlPullUtil.enter(pp, "itdPartialRouteList");
final List<Trip.Leg> legs = new LinkedList<Trip.Leg>();
final List<Trip.Leg> legs = new LinkedList<>();
Location firstDepartureLocation = null;
Location lastArrivalLocation = null;
@ -2381,7 +2381,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "itdPartialRouteList");
final List<Fare> fares = new ArrayList<Fare>(2);
final List<Fare> fares = new ArrayList<>(2);
if (XmlPullUtil.test(pp, "itdFare")) {
if (!pp.isEmptyElementTag()) {
XmlPullUtil.enter(pp, "itdFare");
@ -2565,7 +2565,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
List<Stop> intermediateStops = null;
if (XmlPullUtil.test(pp, "itdStopSeq")) {
XmlPullUtil.enter(pp, "itdStopSeq");
intermediateStops = new LinkedList<Stop>();
intermediateStops = new LinkedList<>();
while (XmlPullUtil.test(pp, "itdPoint")) {
final Location stopLocation = processItdPointAttributes(pp);
@ -2657,7 +2657,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "nextDeps");
}
final Set<Line.Attr> lineAttrs = new HashSet<Line.Attr>();
final Set<Line.Attr> lineAttrs = new HashSet<>();
if (wheelChairAccess || lowFloorVehicle)
lineAttrs.add(Line.Attr.WHEEL_CHAIR_ACCESS);
final Line styledLine = new Line(line.id, line.network, line.product, line.label,
@ -2684,7 +2684,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final Calendar plannedTimeCal = new GregorianCalendar(timeZone);
final Calendar predictedTimeCal = new GregorianCalendar(timeZone);
final List<Trip> trips = new ArrayList<Trip>();
final List<Trip> trips = new ArrayList<>();
if (XmlPullUtil.test(pp, "ts")) {
if (!pp.isEmptyElementTag()) {
@ -2704,7 +2704,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "ls");
final List<Trip.Leg> legs = new LinkedList<Trip.Leg>();
final List<Trip.Leg> legs = new LinkedList<>();
Location firstDepartureLocation = null;
Location lastArrivalLocation = null;
@ -2784,7 +2784,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
if (!pp.isEmptyElementTag()) {
XmlPullUtil.enter(pp, "pss");
intermediateStops = new LinkedList<Stop>();
intermediateStops = new LinkedList<>();
while (XmlPullUtil.test(pp, "s")) {
plannedTimeCal.clear();
@ -2877,7 +2877,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
if (!pp.isEmptyElementTag()) {
XmlPullUtil.enter(pp, "tcs");
fares = new ArrayList<Fare>(2);
fares = new ArrayList<>(2);
XmlPullUtil.optSkipMultiple(pp, "tc"); // TODO fares
XmlPullUtil.skipExit(pp, "tcs");
} else {
@ -2937,7 +2937,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
private List<Point> processCoordinateStrings(final XmlPullParser pp, final String tag)
throws XmlPullParserException, IOException {
final List<Point> path = new LinkedList<Point>();
final List<Point> path = new LinkedList<>();
final String value = XmlPullUtil.valueTag(pp, tag);
for (final String coordStr : value.split(" +"))
@ -2947,7 +2947,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
}
private List<Point> processCoordinateBaseElems(final XmlPullParser pp) throws XmlPullParserException, IOException {
final List<Point> path = new LinkedList<Point>();
final List<Point> path = new LinkedList<>();
XmlPullUtil.enter(pp, "itdCoordinateBaseElemList");
@ -3090,7 +3090,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
return location.name;
}
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<>();
static {
WALKSPEED_MAP.put(WalkSpeed.SLOW, "slow");
@ -3170,7 +3170,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
}
private Map<String, String> processPas(final XmlPullParser pp) throws XmlPullParserException, IOException {
final Map<String, String> params = new HashMap<String, String>();
final Map<String, String> params = new HashMap<>();
XmlPullUtil.enter(pp, "pas");

View file

@ -321,7 +321,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final Matcher mJson = P_AJAX_GET_STOPS_JSON.matcher(page);
if (mJson.matches()) {
final String json = mJson.group(1);
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
try {
final JSONObject head = new JSONObject(json);
@ -436,7 +436,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
protected final QueryDeparturesResult xmlStationBoard(final HttpUrl url, final String stationId)
throws IOException {
final String normalizedStationId = normalizeStationId(stationId);
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<QueryDeparturesResult>();
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
httpClient.getInputStream(new HttpClient.Callback() {
@ -783,7 +783,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final String request = wrapReqC(conReq, null);
final HttpUrl endpoint = extXmlEndpoint != null ? extXmlEndpoint
: queryEndpoint.newBuilder().addPathSegment(apiLanguage).build();
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
httpClient.getInputStream(new HttpClient.Callback() {
@Override
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
@ -917,7 +917,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
XmlPullUtil.enter(pp, "ConnectionList");
final List<Trip> trips = new ArrayList<Trip>();
final List<Trip> trips = new ArrayList<>();
while (XmlPullUtil.test(pp, "Connection")) {
final String id = context.sequence + "/" + XmlPullUtil.attr(pp, "id");
@ -969,7 +969,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
XmlPullUtil.skipExit(pp, "Overview");
final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(4);
final List<Trip.Leg> legs = new ArrayList<>(4);
XmlPullUtil.enter(pp, "ConSectionList");
@ -1040,7 +1040,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
XmlPullUtil.skipExit(pp, "JourneyAttributeList");
if (XmlPullUtil.test(pp, "PassList")) {
intermediateStops = new LinkedList<Stop>();
intermediateStops = new LinkedList<>();
XmlPullUtil.enter(pp, "PassList");
while (XmlPullUtil.test(pp, "BasicStop")) {
@ -1101,7 +1101,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
// polyline
final List<Point> path;
if (XmlPullUtil.test(pp, "Polyline")) {
path = new LinkedList<Point>();
path = new LinkedList<>();
XmlPullUtil.enter(pp, "Polyline");
while (XmlPullUtil.test(pp, "Point")) {
final int x = XmlPullUtil.intAttr(pp, "x");
@ -1196,7 +1196,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
private final Map<String, String> parseAttributeVariants(final XmlPullParser pp)
throws XmlPullParserException, IOException {
final Map<String, String> attributeVariants = new HashMap<String, String>();
final Map<String, String> attributeVariants = new HashMap<>();
while (XmlPullUtil.test(pp, "AttributeVariant")) {
final String type = XmlPullUtil.attr(pp, "type");
@ -1418,7 +1418,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
* Many thanks to Malte Starostik and Robert, who helped a lot with analyzing this API!
*/
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
httpClient.getInputStream(new HttpClient.Callback() {
@Override
@ -1552,7 +1552,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final CommentTable comments = new CommentTable(is, commentTablePtr,
tripDetailsPtr - commentTablePtr, strings);
final List<Trip> trips = new ArrayList<Trip>(numTrips);
final List<Trip> trips = new ArrayList<>(numTrips);
// read trips
for (int iTrip = 0; iTrip < numTrips; iTrip++) {
@ -1628,7 +1628,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
}
}
final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(numLegs);
final List<Trip.Leg> legs = new ArrayList<>(numLegs);
for (int iLegs = 0; iLegs < numLegs; iLegs++) {
is.reset();
@ -1649,7 +1649,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final int legAttrIndex = is.readShortReverse();
final List<Line.Attr> lineAttrs = new ArrayList<Line.Attr>();
final List<Line.Attr> lineAttrs = new ArrayList<>();
String lineComment = null;
boolean lineOnDemand = false;
for (final String comment : comments.read(is)) {
@ -1780,7 +1780,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
if (stopsSize != 26)
throw new IllegalStateException("unhandled stops size: " + stopsSize);
intermediateStops = new ArrayList<Stop>(numStops);
intermediateStops = new ArrayList<>(numStops);
for (int iStop = 0; iStop < numStops; iStop++) {
final long plannedStopDepartureTime = time(is, resDate, tripDayOffset);
@ -2242,7 +2242,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
// scrape page
final CharSequence page = httpClient.get(url);
final List<Location> stations = new ArrayList<Location>();
final List<Location> stations = new ArrayList<>();
// parse page
final Matcher mMessage = P_XML_NEARBY_STATIONS_MESSAGES.matcher(page);
@ -2322,7 +2322,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final JSONObject head = new JSONObject(page.toString());
final int error = head.getInt("error");
if (error == 0) {
final List<Location> locations = new LinkedList<Location>();
final List<Location> locations = new LinkedList<>();
final JSONArray aStops = head.optJSONArray("stops");
if (aStops != null) {
@ -2396,7 +2396,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
.compile("(Ihre Eingabe kann nicht interpretiert werden)");
protected final NearbyLocationsResult htmlNearbyStations(final HttpUrl url) throws IOException {
final List<Location> stations = new ArrayList<Location>();
final List<Location> stations = new ArrayList<>();
final CharSequence page = httpClient.get(url);
String oldZebra = null;
@ -3034,7 +3034,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
return new Line(null, network, product, normalizedName, lineStyle(network, product, normalizedName),
comment);
} else {
final Set<Line.Attr> attrSet = new HashSet<Line.Attr>();
final Set<Line.Attr> attrSet = new HashSet<>();
for (final Line.Attr attr : attrs)
attrSet.add(attr);
return new Line(null, network, product, normalizedName, lineStyle(network, product, normalizedName),

View file

@ -334,7 +334,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
final JSONObject match = res.getJSONObject("match");
final List<Location> locations = parseLocList(match.optJSONArray("locL"));
final List<SuggestedLocation> suggestedLocations = new ArrayList<SuggestedLocation>(locations.size());
final List<SuggestedLocation> suggestedLocations = new ArrayList<>(locations.size());
for (final Location location : locations)
suggestedLocations.add(new SuggestedLocation(location));
// TODO weight
@ -444,7 +444,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
final List<Line> lines = parseProdList(common.getJSONArray("prodL"), operators);
final JSONArray outConList = res.optJSONArray("outConL");
final List<Trip> trips = new ArrayList<Trip>(outConList.length());
final List<Trip> trips = new ArrayList<>(outConList.length());
for (int iOutCon = 0; iOutCon < outConList.length(); iOutCon++) {
final JSONObject outCon = outConList.getJSONObject(iOutCon);
final Location tripFrom = locations.get(outCon.getJSONObject("dep").getInt("locX"));
@ -455,7 +455,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
final Date baseDate = c.getTime();
final JSONArray secList = outCon.optJSONArray("secL");
final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(secList.length());
final List<Trip.Leg> legs = new ArrayList<>(secList.length());
for (int iSec = 0; iSec < secList.length(); iSec++) {
final JSONObject sec = secList.getJSONObject(iSec);
final String secType = sec.getString("type");
@ -476,7 +476,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
final JSONArray stopList = jny.getJSONArray("stopL");
checkState(stopList.length() >= 2);
final List<Stop> intermediateStops = new ArrayList<Stop>(stopList.length());
final List<Stop> intermediateStops = new ArrayList<>(stopList.length());
for (int iStop = 1; iStop < stopList.length() - 1; iStop++) {
final JSONObject stop = stopList.getJSONObject(iStop);
final Stop intermediateStop = parseJsonStop(stop, locations, c, baseDate);
@ -499,7 +499,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
}
final JSONObject trfRes = outCon.optJSONObject("trfRes");
final List<Fare> fares = new LinkedList<Fare>();
final List<Fare> fares = new LinkedList<>();
if (trfRes != null) {
final JSONArray fareSetList = trfRes.getJSONArray("fareSetL");
for (int iFareSet = 0; iFareSet < fareSetList.length(); iFareSet++) {
@ -636,7 +636,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
}
private List<String[]> parseRemList(final JSONArray remList) throws JSONException {
final List<String[]> remarks = new ArrayList<String[]>(remList.length());
final List<String[]> remarks = new ArrayList<>(remList.length());
for (int i = 0; i < remList.length(); i++) {
final JSONObject rem = remList.getJSONObject(i);
@ -649,7 +649,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
}
private List<Location> parseLocList(final JSONArray locList) throws JSONException {
final List<Location> locations = new ArrayList<Location>(locList.length());
final List<Location> locations = new ArrayList<>(locList.length());
for (int iLoc = 0; iLoc < locList.length(); iLoc++) {
final JSONObject loc = locList.getJSONObject(iLoc);
@ -691,7 +691,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
}
private List<String> parseOpList(final JSONArray opList) throws JSONException {
final List<String> operators = new ArrayList<String>(opList.length());
final List<String> operators = new ArrayList<>(opList.length());
for (int i = 0; i < opList.length(); i++) {
final JSONObject op = opList.getJSONObject(i);
@ -703,7 +703,7 @@ public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider
}
private List<Line> parseProdList(final JSONArray prodList, final List<String> operators) throws JSONException {
final List<Line> lines = new ArrayList<Line>(prodList.length());
final List<Line> lines = new ArrayList<>(prodList.length());
for (int iProd = 0; iProd < prodList.length(); iProd++) {
final JSONObject prod = prodList.getJSONObject(iProd);

View file

@ -304,7 +304,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
}
private LinkedList<Point> parsePath(final JSONArray coordinates) throws IOException {
LinkedList<Point> path = new LinkedList<Point>();
LinkedList<Point> path = new LinkedList<>();
for (int i = 0; i < coordinates.length(); ++i) {
try {
@ -494,7 +494,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
final Stop arrivalStop = parseStop(stopDateTimes.getJSONObject(nbStopDateTime - 1));
// Build intermediate stops.
final LinkedList<Stop> intermediateStops = new LinkedList<Stop>();
final LinkedList<Stop> intermediateStops = new LinkedList<>();
for (int i = 1; i < nbStopDateTime - 1; ++i) {
final Stop intermediateStop = parseStop(stopDateTimes.getJSONObject(i));
intermediateStops.add(intermediateStop);
@ -555,7 +555,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
final int changeCount = journey.getInt("nb_transfers");
// Build leg list.
final List<Leg> legs = new LinkedList<Leg>();
final List<Leg> legs = new LinkedList<>();
final JSONArray sections = journey.getJSONArray("sections");
for (int j = 0; j < sections.length(); ++j) {
@ -707,7 +707,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
if (nbResults == 0) {
return new NearbyLocationsResult(resultHeader, Status.INVALID_ID);
} else {
final List<Location> stations = new ArrayList<Location>();
final List<Location> stations = new ArrayList<>();
final JSONArray places = head.getJSONArray("places_nearby");
@ -837,7 +837,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
final CharSequence page = httpClient.get(url.build());
try {
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
@ -1086,7 +1086,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
final String shape = regionInfo.getString("shape");
// Parse string using JSON tokenizer for coordinates.
List<Point> pointList = new ArrayList<Point>();
List<Point> pointList = new ArrayList<>();
final JSONTokener shapeTokener = new JSONTokener(shape);
shapeTokener.skipTo('(');
shapeTokener.next();

View file

@ -123,7 +123,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
private static final String DEFAULT_TRIP_ENDPOINT = "journeyplanner/v2";
private static final String SERVER_PRODUCT = "tsi";
private static Map<String, Product> TRANSPORT_MODES = new HashMap<String, Product>();
private static Map<String, Product> TRANSPORT_MODES = new HashMap<>();
static {
// HIGH_SPEED_TRAIN
TRANSPORT_MODES.put("TGV", Product.HIGH_SPEED_TRAIN);
@ -200,7 +200,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
final CharSequence page = httpClient.get(url.build());
try {
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
@ -258,7 +258,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
final List<Location> locations = suggestLocations(location.uniqueShortName()).getLocations();
if (locations == null)
return new ArrayList<Location>(0);
return new ArrayList<>(0);
return locations;
}
@ -275,7 +275,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
final CharSequence page = httpClient.get(url.build());
try {
final List<Location> stations = new ArrayList<Location>();
final List<Location> stations = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
@ -352,7 +352,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
}
final JSONArray pathLinks = legInfo.getJSONObject("pathLinks").getJSONArray("PathLink");
final List<Point> path = new ArrayList<Point>(pathLinks.length() + 1);
final List<Point> path = new ArrayList<>(pathLinks.length() + 1);
int distance = 0;
path.add(new Point(departure.lat, departure.lon));
@ -440,7 +440,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
}
final JSONArray stepArray = ptrInfo.getJSONObject("steps").getJSONArray("Step");
List<Stop> intermediateStops = new ArrayList<Stop>(stepArray.length() - 1);
List<Stop> intermediateStops = new ArrayList<>(stepArray.length() - 1);
for (int i = 0; i < stepArray.length() - 1; i++) {
final JSONObject enterStop = stepArray.getJSONObject(i).getJSONObject("Arrival");
final JSONObject leaveStop = stepArray.getJSONObject(i + 1).getJSONObject("Departure");
@ -469,7 +469,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
final Location to = parseJsonJourneyplannerLocation(arrivalInfo.getJSONObject("Site"));
final JSONArray legArray = tripObject.getJSONObject("sections").getJSONArray("Section");
final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(legArray.length());
final List<Trip.Leg> legs = new ArrayList<>(legArray.length());
for (int i = 0; i < legArray.length(); i++) {
legs.add(parseJsonJourneyplannerLeg(legArray.getJSONObject(i)));
@ -688,7 +688,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider {
}
final JSONArray tripArray = head.getJSONObject("trips").getJSONArray("Trip");
final List<Trip> trips = new ArrayList<Trip>(tripArray.length());
final List<Trip> trips = new ArrayList<>(tripArray.length());
for (int i = 0; i < tripArray.length(); i++) {
final JSONObject tripObject = tripArray.getJSONObject(i);

View file

@ -87,7 +87,7 @@ public class AvvProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("B", new Style(Style.Shape.CIRCLE, Style.parseColor("#abb1b1"), Style.BLACK));

View file

@ -59,7 +59,7 @@ public class BsvagProvider extends AbstractEfaProvider {
url.addEncodedQueryParameter("inclMOT_11", "on");
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Braunschweig

View file

@ -148,7 +148,7 @@ public final class BvgProvider extends AbstractHafasMobileProvider {
return null;
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("SS1", new Style(Style.rgb(221, 77, 174), Style.WHITE));

View file

@ -65,7 +65,7 @@ public class GvhProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Hannover

View file

@ -141,7 +141,7 @@ public class HslProvider extends AbstractNetworkProvider {
final HttpUrl.Builder url = apiUrl("stop");
url.addQueryParameter("code", stationId);
url.addQueryParameter("dep_limit", "1");
final AtomicReference<Location> result = new AtomicReference<Location>();
final AtomicReference<Location> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -184,7 +184,7 @@ public class HslProvider extends AbstractNetworkProvider {
url.addQueryParameter("center_coordinate", locationToCoords(location));
url.addQueryParameter("limit", Integer.toString(maxStations));
url.addQueryParameter("diameter", Integer.toString(maxDistance * 2));
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<NearbyLocationsResult>();
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -193,7 +193,7 @@ public class HslProvider extends AbstractNetworkProvider {
final XmlPullParser pp = parserFactory.newPullParser();
pp.setInput(body.charStream());
final List<Location> stations = new ArrayList<Location>();
final List<Location> stations = new ArrayList<>();
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
XmlPullUtil.enter(pp, "response");
@ -262,7 +262,7 @@ public class HslProvider extends AbstractNetworkProvider {
url.addQueryParameter("time", new SimpleDateFormat("HHmm").format(queryDate));
}
url.addQueryParameter("dep_limit", Integer.toString(maxDepartures));
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<QueryDeparturesResult>();
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -278,7 +278,7 @@ public class HslProvider extends AbstractNetworkProvider {
final String id = xmlValueTag(pp, "code");
final String name = xmlValueTag(pp, "name_fi");
final Map<String, Line> lines = new HashMap<String, Line>();
final Map<String, Line> lines = new HashMap<>();
XmlPullUtil.skipUntil(pp, "lines");
XmlPullUtil.enter(pp, "lines");
@ -294,7 +294,7 @@ public class HslProvider extends AbstractNetworkProvider {
XmlPullUtil.skipUntil(pp, "departures");
XmlPullUtil.enter(pp, "departures");
final List<Departure> departures = new ArrayList<Departure>(maxDepartures);
final List<Departure> departures = new ArrayList<>(maxDepartures);
while (XmlPullUtil.test(pp, "node")) {
XmlPullUtil.enter(pp, "node");
final String code = xmlValueTag(pp, "code");
@ -341,14 +341,14 @@ public class HslProvider extends AbstractNetworkProvider {
// name.
String constraintStr = constraint.toString().replaceAll("[^\\p{Ll}\\p{Lu}\\p{Lt}\\p{Lo}\\p{Nd}\\d-'/ ]", "");
url.addQueryParameter("key", constraintStr);
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<SuggestLocationsResult>();
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
try {
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
final XmlPullParser pp = parserFactory.newPullParser();
pp.setInput(body.charStream());
@ -417,7 +417,7 @@ public class HslProvider extends AbstractNetworkProvider {
this.via = via;
this.to = to;
this.date = date;
this.trips = new ArrayList<Trip>();
this.trips = new ArrayList<>();
}
@Override
@ -480,7 +480,7 @@ public class HslProvider extends AbstractNetworkProvider {
url.addQueryParameter("show", "5");
if (products != null && products.size() > 0) {
List<String> tt = new ArrayList<String>();
List<String> tt = new ArrayList<>();
if (products.contains(Product.HIGH_SPEED_TRAIN) || products.contains(Product.REGIONAL_TRAIN)
|| products.contains(Product.SUBURBAN_TRAIN))
tt.add("train");
@ -550,7 +550,7 @@ public class HslProvider extends AbstractNetworkProvider {
final HttpUrl.Builder url = HttpUrl.parse(context.uri).newBuilder();
url.addQueryParameter("date", new SimpleDateFormat("yyyyMMdd").format(date));
url.addQueryParameter("time", new SimpleDateFormat("HHmm").format(date));
final AtomicReference<QueryTripsResult> result = new AtomicReference<QueryTripsResult>();
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {
@Override
@ -563,10 +563,10 @@ public class HslProvider extends AbstractNetworkProvider {
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final List<Trip> trips = new ArrayList<Trip>(context.trips);
final List<Trip> trips = new ArrayList<>(context.trips);
// we use this for quick checking if trip already exists
Set<String> tripSet = new HashSet<String>();
Set<String> tripSet = new HashSet<>();
for (Trip t : trips)
tripSet.add(t.getId());
@ -577,7 +577,7 @@ public class HslProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "node");
List<Trip.Leg> legs = new ArrayList<Trip.Leg>();
List<Trip.Leg> legs = new ArrayList<>();
XmlPullUtil.skipUntil(pp, "legs");
XmlPullUtil.enter(pp, "legs");
@ -590,7 +590,7 @@ public class HslProvider extends AbstractNetworkProvider {
String legType = xmlValueTag(pp, "type");
String lineCode = XmlPullUtil.optValueTag(pp, "code", null);
List<Point> path = new ArrayList<Point>();
List<Point> path = new ArrayList<>();
Location departure = null;
Date departureTime = null;
@ -599,7 +599,7 @@ public class HslProvider extends AbstractNetworkProvider {
Location arrival = null;
Date arrivalTime = null;
LinkedList<Stop> stops = new LinkedList<Stop>();
LinkedList<Stop> stops = new LinkedList<>();
XmlPullUtil.skipUntil(pp, "locs");
XmlPullUtil.enter(pp, "locs");

View file

@ -196,7 +196,7 @@ public class InvgProvider extends AbstractHafasLegacyProvider {
currentTime.clear();
ParserUtils.parseGermanDate(currentTime, mHeadFine.group(2));
ParserUtils.parseEuropeanTime(currentTime, mHeadFine.group(3));
final List<Departure> departures = new ArrayList<Departure>(8);
final List<Departure> departures = new ArrayList<>(8);
String oldZebra = null;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(3));
@ -330,7 +330,7 @@ public class InvgProvider extends AbstractHafasLegacyProvider {
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("B10", new Style(Style.parseColor("#DA2510"), Style.WHITE));

View file

@ -74,7 +74,7 @@ public class KvvProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// S-Bahn

View file

@ -38,7 +38,7 @@ public class LinzProvider extends AbstractEfaProvider {
setStyles(STYLES);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("B11", new Style(Style.Shape.RECT, Style.parseColor("#f27b02"), Style.WHITE));

View file

@ -95,7 +95,7 @@ public class MvvProvider extends AbstractEfaProvider {
return super.parsePosition(position);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("SS1", new Style(Style.parseColor("#00ccff"), Style.WHITE));

View file

@ -154,7 +154,7 @@ public class SeptaProvider extends AbstractHafasLegacyProvider {
ParserUtils.parseAmericanDate(currentTime, mPageCoarse.group(2));
ParserUtils.parseAmericanTime(currentTime, mPageCoarse.group(3));
final List<Departure> departures = new ArrayList<Departure>(8);
final List<Departure> departures = new ArrayList<>(8);
String oldZebra = null;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mPageCoarse.group(4));

View file

@ -91,7 +91,7 @@ public class ShProvider extends AbstractHafasMobileProvider {
return new Fare("SH-Tarif", Type.ADULT, currency, price, name, null);
}
protected static final Map<String, Style> STYLES = new HashMap<String, Style>();
protected static final Map<String, Style> STYLES = new HashMap<>();
static {
// Busse Kiel

View file

@ -36,7 +36,7 @@ public class Standard {
public static final int COLOR_BACKGROUND_BUS = Style.parseColor("#993399");
public static final int COLOR_BACKGROUND_FERRY = Style.BLUE;
public static final Map<Product, Style> STYLES = new HashMap<Product, Style>();
public static final Map<Product, Style> STYLES = new HashMap<>();
static {
STYLES.put(Product.HIGH_SPEED_TRAIN,

View file

@ -80,7 +80,7 @@ public class SvvProvider extends AbstractHafasMobileProvider {
return super.splitAddress(address);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("svv|SS1", new Style(Style.parseColor("#b61d33"), Style.WHITE));

View file

@ -174,7 +174,7 @@ public class SydneyProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
STYLES.put("SBMT", new Style(Style.parseColor("#f5a81d"), Style.WHITE));

View file

@ -81,7 +81,7 @@ public class TlemProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// London

View file

@ -55,7 +55,7 @@ public class VagfrProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Tram

View file

@ -79,7 +79,7 @@ public class VaoProvider extends AbstractHafasMobileProvider {
return super.splitAddress(address);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Salzburg S-Bahn

View file

@ -76,7 +76,7 @@ public class VbnProvider extends AbstractHafasMobileProvider {
return Product.ALL;
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Rostock

View file

@ -79,7 +79,7 @@ public class VorProvider extends AbstractHafasMobileProvider {
return super.splitAddress(address);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Wien

View file

@ -63,7 +63,7 @@ public class VrnProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Straßen- und Stadtbahn Mannheim-Ludwigshafen rnv

View file

@ -101,7 +101,7 @@ public class VrrProvider extends AbstractEfaProvider {
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Schnellbusse VRR

View file

@ -174,7 +174,7 @@ public class VrsProvider extends AbstractNetworkProvider {
};
protected static final Pattern nrwTarifPattern = Pattern.compile("([\\d]+,\\d\\d)");
protected static final Map<String, Style> STYLES = new HashMap<String, Style>();
protected static final Map<String, Style> STYLES = new HashMap<>();
static {
// Stadtbahn Köln-Bonn
@ -380,7 +380,7 @@ public class VrsProvider extends AbstractNetworkProvider {
final CharSequence page = httpClient.get(url.build());
try {
final List<Location> locations = new ArrayList<Location>();
final List<Location> locations = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
final String error = Strings.emptyToNull(head.optString("error", "").trim());
if (error != null) {
@ -592,7 +592,7 @@ public class VrsProvider extends AbstractNetworkProvider {
final CharSequence page = httpClient.get(url.build());
try {
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
final List<SuggestedLocation> locations = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
final String error = Strings.emptyToNull(head.optString("error", "").trim());
@ -660,13 +660,13 @@ public class VrsProvider extends AbstractNetworkProvider {
@Nullable Set<Option> options) throws IOException {
// The EXACT_POINTS feature generates an about 50% bigger API response, probably well compressible.
final boolean EXACT_POINTS = true;
final List<Location> ambiguousFrom = new ArrayList<Location>();
final List<Location> ambiguousFrom = new ArrayList<>();
String fromString = generateLocation(from, ambiguousFrom);
final List<Location> ambiguousVia = new ArrayList<Location>();
final List<Location> ambiguousVia = new ArrayList<>();
String viaString = generateLocation(via, ambiguousVia);
final List<Location> ambiguousTo = new ArrayList<Location>();
final List<Location> ambiguousTo = new ArrayList<>();
String toString = generateLocation(to, ambiguousTo);
if (!ambiguousFrom.isEmpty() || !ambiguousVia.isEmpty() || !ambiguousTo.isEmpty()) {
@ -704,7 +704,7 @@ public class VrsProvider extends AbstractNetworkProvider {
final CharSequence page = httpClient.get(url.build());
try {
final List<Trip> trips = new ArrayList<Trip>();
final List<Trip> trips = new ArrayList<>();
final JSONObject head = new JSONObject(page.toString());
final String error = Strings.emptyToNull(head.optString("error", "").trim());
if (error != null) {
@ -750,7 +750,7 @@ public class VrsProvider extends AbstractNetworkProvider {
for (int iRoute = 0; iRoute < routes.length(); iRoute++) {
final JSONObject route = routes.getJSONObject(iRoute);
final JSONArray segments = route.getJSONArray("segments");
List<Leg> legs = new ArrayList<Leg>();
List<Leg> legs = new ArrayList<>();
Location tripOrigin = null;
Location tripDestination = null;
// for all segments
@ -780,7 +780,7 @@ public class VrsProvider extends AbstractNetworkProvider {
}
tripDestination = segmentDestination;
}
List<Stop> intermediateStops = new ArrayList<Stop>();
List<Stop> intermediateStops = new ArrayList<>();
final JSONArray vias = segment.optJSONArray("vias");
if (vias != null) {
for (int iVia = 0; iVia < vias.length(); iVia++) {
@ -854,7 +854,7 @@ public class VrsProvider extends AbstractNetworkProvider {
}
}
List<Point> points = new ArrayList<Point>();
List<Point> points = new ArrayList<>();
points.add(new Point(segmentOrigin.lat, segmentOrigin.lon));
if (EXACT_POINTS && segment.has("polygon")) {
parsePolygon(segment.getString("polygon"), points);
@ -911,7 +911,7 @@ public class VrsProvider extends AbstractNetworkProvider {
}
private static List<Fare> parseFare(final JSONObject costs) throws JSONException {
List<Fare> fares = new ArrayList<Fare>();
List<Fare> fares = new ArrayList<>();
if (costs != null) {
final String name = costs.optString("name", null); // e.g. "VRS-Tarif", "NRW-Tarif"
final String text = costs.optString("text", null); // e.g. "Preisstufe 4 [RegioTicket] 7,70 €",

View file

@ -63,7 +63,7 @@ public class WienProvider extends AbstractEfaProvider {
}
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// Wien

View file

@ -179,7 +179,7 @@ public class ZvvProvider extends AbstractHafasLegacyProvider {
return super.normalizeType(type);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<>();
static {
// S-Bahn

View file

@ -39,7 +39,7 @@ public final class QueryDeparturesResult implements Serializable {
public final @Nullable ResultHeader header;
public final Status status;
public final List<StationDepartures> stationDepartures = new LinkedList<StationDepartures>();
public final List<StationDepartures> stationDepartures = new LinkedList<>();
public QueryDeparturesResult(final ResultHeader header) {
this.header = header;

View file

@ -46,7 +46,7 @@ public final class SuggestLocationsResult implements Serializable {
public SuggestLocationsResult(final ResultHeader header, final List<SuggestedLocation> suggestedLocations) {
this.header = header;
this.status = Status.OK;
this.suggestedLocations = new LinkedList<SuggestedLocation>(suggestedLocations);
this.suggestedLocations = new LinkedList<>(suggestedLocations);
Collections.sort(this.suggestedLocations);
}
@ -57,7 +57,7 @@ public final class SuggestLocationsResult implements Serializable {
}
public List<Location> getLocations() {
final List<Location> locations = new ArrayList<Location>(suggestedLocations.size());
final List<Location> locations = new ArrayList<>(suggestedLocations.size());
for (final SuggestedLocation location : suggestedLocations)
locations.add(location.location);

View file

@ -68,7 +68,7 @@ import okhttp3.logging.HttpLoggingInterceptor;
public final class HttpClient {
@Nullable
private String userAgent = null;
private Map<String, String> headers = new HashMap<String, String>();
private Map<String, String> headers = new HashMap<>();
@Nullable
private String sessionCookieName = null;
@Nullable

View file

@ -518,7 +518,7 @@ public class VrsProviderLiveTest extends AbstractProviderLiveTest {
}
private void crawlStationsAndLines(int latFrom, int latTo, int lonFrom, int lonTo) throws Exception {
Set<Location> stations = new TreeSet<Location>(new LocationComparator());
Set<Location> stations = new TreeSet<>(new LocationComparator());
Random rand = new Random(new Date().getTime());
for (int i = 0; i < 5; i++) {
int lat = latFrom + rand.nextInt(latTo - latFrom);
@ -530,7 +530,7 @@ public class VrsProviderLiveTest extends AbstractProviderLiveTest {
stations.addAll(result.locations);
}
}
Set<Line> lines = new TreeSet<Line>();
Set<Line> lines = new TreeSet<>();
for (Location station : stations) {
QueryDeparturesResult qdr = provider.queryDepartures(station.id,
Iso8601Format.parseDateTime("2015-03-16 02:00:00"), 100, false);