Skip to content

Commit

Permalink
JDK 21 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahil S committed Aug 7, 2024
1 parent cf5c0b8 commit 5289530
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 56 deletions.
11 changes: 6 additions & 5 deletions cab-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<version>0.0.1-SNAPSHOT</version>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -68,14 +68,15 @@
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>spring-boot-maven-plugin</artifactId>
<groupId>org.springframework.boot</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Cab getMostSuitableCab(Integer fromCity) {
throw new RuntimeException("No cabs Available");
}
idleCabs.sort((a, b) -> (int) (a.getIdleFrom() - b.getIdleFrom()));
return idleCabs.get(0);
return idleCabs.getFirst();
}

public void update(Integer cabId, Integer cityId, CabStatus state) {
Expand Down
10 changes: 3 additions & 7 deletions cab-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
<modelVersion>4.0.0</modelVersion>
<name>cab-commons</name>
<version>0.0.1-SNAPSHOT</version>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -50,18 +49,15 @@
<version>5.10.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
<release>${java.version}</release>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package in.rsh.cab.commons.model;


public record DrivingLicense(String photoURL, String licenseNo) {}
public record DrivingLicense(String photoURL, String licenseNo) {
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
package in.rsh.cab.commons.model;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class Location {
private final int latitude;
private final int longitude;
public record Location(int latitude, int longitude) {
}
25 changes: 12 additions & 13 deletions cab-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@
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">
<artifactId>cab-user</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>in.rsh.cab.commons</groupId>
Expand All @@ -26,7 +14,7 @@
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
<scope>provided</scope>
<version>1.18.32</version>
<version>1.18.34</version>
</dependency>
<dependency>
<artifactId>json</artifactId>
Expand All @@ -51,4 +39,15 @@
<url>http://maven.apache.org</url>

<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>21</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public Booking bookCab(Rider rider) {

private boolean isDistanceMoreThanThreshold(Location currentLocation, Location location) {
return (Math.sqrt(
Math.pow(currentLocation.getLatitude() - location.getLatitude(), 2)
+ Math.pow(currentLocation.getLongitude() - location.getLongitude(), 2)))
Math.pow(currentLocation.latitude() - location.latitude(), 2)
+ Math.pow(currentLocation.longitude() - location.longitude(), 2)))
> MAX_DISTANCE_DRIVER_CAN_TRAVEL;
}

private int getNearestCab(Location location, Location location1) {
return ((location.getLatitude() + location.getLongitude())
- (location1.getLatitude() + location1.getLongitude()));
return ((location.latitude() + location.longitude())
- (location1.latitude() + location1.longitude()));
}

public List<Booking> getBookingsForRider(Rider rider) {
Expand Down
31 changes: 14 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<artifactId>cab</artifactId>
<groupId>in.rsh.cab</groupId>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>cab-user</module>
<module>cab-admin</module>
<module>cab-commons</module>
</modules>
<name>cab</name>
<packaging>pom</packaging>
<properties>
<java.version>17</java.version>
</properties>
<url>http://maven.apache.org</url>
<version>1.0-SNAPSHOT</version>
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<artifactId>cab</artifactId>
<groupId>in.rsh.cab</groupId>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>cab-user</module>
<module>cab-admin</module>
<module>cab-commons</module>
</modules>
<name>cab</name>
<packaging>pom</packaging>
<url>http://maven.apache.org</url>
<version>1.0-SNAPSHOT</version>
</project>

0 comments on commit 5289530

Please sign in to comment.