diff --git a/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/object-class-guide/Car.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/object-class-guide/Car.java new file mode 100644 index 000000000000..2345247b9c9a --- /dev/null +++ b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/object-class-guide/Car.java @@ -0,0 +1,76 @@ +import java.util.Objects; + + +/** + * Represents a car object, implementing Cloneable and overriding Object methods. + * + * The class uses standard implementation for equals(), hashCode(), and toString(). + * The clone() method performs a shallow copy, which is sufficient since 'make' (String) + * and 'year' (int) are immutable or primitive. + */ +public class Car implements Cloneable { + private String make; + private int year; + + + public Car(String make, int year) { + this.make = make; + this.year = year; + } + + + // Getters for external access (useful for testing) + public String getMake() { + return make; + } + + + public int getYear() { + return year; + } + + + /** + * Standard implementation of equals() for value equality. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Car car = (Car) obj; + // Use Objects.equals for safe String comparison + return year == car.year && Objects.equals(make, car.make); + } + + + /** + * Standard implementation of hashCode() based on make and year. + */ + @Override + public int hashCode() { + return Objects.hash(make, year); + } + + + /** + * Standard implementation of toString() for debugging and logging. + */ + @Override + public String toString() { + return "Car{" + + "make='" + make + '\'' + + ", year=" + year + + '}'; + } + + + /** + * Overrides the protected clone() method from Object to perform a shallow copy. + * This is the standard pattern when implementing the Cloneable marker interface. + */ + @Override + public Object clone() throws CloneNotSupportedException { + // Calls Object's native clone() method + return super.clone(); + } +} diff --git a/spring-boot-modules/spring-boot-caching/pom.xml b/spring-boot-modules/spring-boot-caching/pom.xml index 010e6079ae34..ec38c8c7d99b 100644 --- a/spring-boot-modules/spring-boot-caching/pom.xml +++ b/spring-boot-modules/spring-boot-caching/pom.xml @@ -15,10 +15,64 @@ + org.springframework.boot spring-boot-starter-web - + + + org.springframework + spring-context + + + org.springframework + spring-core + + + org.springframework + spring-beans + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + + + + org.springframework.boot + spring-boot-starter-cache + + + org.springframework + spring-context + + + org.springframework + spring-core + + + org.springframework + spring-beans + + + + + org.springframework spring-context @@ -30,17 +84,28 @@ 6.2.11 - org.springframework.boot - spring-boot-starter-cache + org.springframework + spring-core + 6.2.11 + + + org.springframework + spring-beans + 6.2.11 org.springframework spring-web + 6.2.11 org.springframework spring-webmvc + 6.2.11 + + + org.ehcache ehcache @@ -49,6 +114,9 @@ org.springframework spring-test + test diff --git a/spring-boot-modules/spring-boot-featureflag-unleash/pom.xml b/spring-boot-modules/spring-boot-featureflag-unleash/pom.xml index 0c93ce4dd977..ddc4ba14a62b 100644 --- a/spring-boot-modules/spring-boot-featureflag-unleash/pom.xml +++ b/spring-boot-modules/spring-boot-featureflag-unleash/pom.xml @@ -43,9 +43,7 @@ org.apache.maven.plugins maven-compiler-plugin - - --enable-preview - +