Skip to content

Commit

Permalink
ENH: NAV-52 - Add LegType to Leg of Public Service Interface
Browse files Browse the repository at this point in the history
- Format project.
  • Loading branch information
munterfi committed May 27, 2024
1 parent ecf3ce8 commit c5dbe98
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 49 deletions.
22 changes: 10 additions & 12 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import java.net.*;
import java.io.*;
import java.nio.channels.*;
Expand All @@ -24,21 +25,18 @@ public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the
* default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
Expand All @@ -54,7 +52,7 @@ public static void main(String args[]) {
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Expand All @@ -65,7 +63,7 @@ public static void main(String args[]) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
Expand All @@ -76,8 +74,8 @@ public static void main(String args[]) {
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
9 changes: 1 addition & 8 deletions src/main/java/ch/naviqore/service/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
*/
public interface Connection {

List<PublicTransitLeg> getPublicTransitLegs();

List<Walk> getWalks();

/**
* The total number of legs and walks in this connection.
*/
int getSize();
List<Leg> getLegs();

}
29 changes: 25 additions & 4 deletions src/main/java/ch/naviqore/service/Leg.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
package ch.naviqore.service;

import org.jetbrains.annotations.Nullable;

import java.time.LocalDateTime;

/**
* Represents a leg of a connection, including its order, distance, and duration.
*/
public interface Leg {

/**
* The position of this leg in the overall connection.
*/
int getOrder();
LegType getLegType();

Location getSourceLocation();

Location getTargetLocation();

LocalDateTime getArrivalTime();

LocalDateTime getDepartureTime();

int getDistance();

int getDuration();

/**
* The target public transit stop, if walk starts at a stop.
*/
@Nullable
Stop getSourceStop();

/**
* The target public transit stop, if walk ends at a stop.
*/
@Nullable
Stop getTargetStop();

}
6 changes: 6 additions & 0 deletions src/main/java/ch/naviqore/service/LegType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ch.naviqore.service;

public enum LegType {
PUBLIC_TRANSIT,
WALK
}
10 changes: 10 additions & 0 deletions src/main/java/ch/naviqore/service/PublicTransitLeg.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package ch.naviqore.service;

import org.jetbrains.annotations.NotNull;

public interface PublicTransitLeg extends Leg {

StopTime getArrival();

StopTime getDeparture();

@Override
@NotNull
Stop getSourceStop();

@Override
@NotNull
Stop getTargetStop();

}
23 changes: 0 additions & 23 deletions src/main/java/ch/naviqore/service/Walk.java

This file was deleted.

0 comments on commit c5dbe98

Please sign in to comment.