diff --git a/annotations/annotation-processing/pom.xml b/annotations/annotation-processing/pom.xml new file mode 100644 index 0000000000..6d07394b87 --- /dev/null +++ b/annotations/annotation-processing/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + + com.baeldung + 1.0.0-SNAPSHOT + annotations + ../ + + + annotation-processing + + + 1.0-rc2 + 3.5.1 + + + + + + com.google.auto.service + auto-service + ${auto-service.version} + provided + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + + + + + + \ No newline at end of file diff --git a/annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProcessor.java b/annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProcessor.java new file mode 100644 index 0000000000..0883e108e7 --- /dev/null +++ b/annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProcessor.java @@ -0,0 +1,132 @@ +package com.baeldung.annotation.processor; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.ExecutableType; +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; + +import com.google.auto.service.AutoService; + +@SupportedAnnotationTypes("com.baeldung.annotation.processor.BuilderProperty") +@SupportedSourceVersion(SourceVersion.RELEASE_8) +@AutoService(Processor.class) +public class BuilderProcessor extends AbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (TypeElement annotation : annotations) { + + Set annotatedElements = roundEnv.getElementsAnnotatedWith(annotation); + + Map> annotatedMethods = annotatedElements.stream() + .collect(Collectors.partitioningBy(element -> + ((ExecutableType) element.asType()).getParameterTypes().size() == 1 + && element.getSimpleName().toString().startsWith("set"))); + + List setters = annotatedMethods.get(true); + List otherMethods = annotatedMethods.get(false); + + otherMethods.forEach(element -> + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "@BuilderProperty must be applied to a setXxx method with a single argument", element)); + + if (setters.isEmpty()) { + continue; + } + + String className = ((TypeElement) setters.get(0).getEnclosingElement()).getQualifiedName().toString(); + + Map setterMap = setters.stream().collect(Collectors.toMap( + setter -> setter.getSimpleName().toString(), + setter -> ((ExecutableType) setter.asType()) + .getParameterTypes().get(0).toString() + )); + + try { + writeBuilderFile(className, setterMap); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + return true; + } + + private void writeBuilderFile(String className, Map setterMap) throws IOException { + + String packageName = null; + int lastDot = className.lastIndexOf('.'); + if (lastDot > 0) { + packageName = className.substring(0, lastDot); + } + + String simpleClassName = className.substring(lastDot + 1); + String builderClassName = className + "Builder"; + String builderSimpleClassName = builderClassName.substring(lastDot + 1); + + JavaFileObject builderFile = processingEnv.getFiler().createSourceFile(builderClassName); + try (PrintWriter out = new PrintWriter(builderFile.openWriter())) { + + if (packageName != null) { + out.print("package "); + out.print(packageName); + out.println(";"); + out.println(); + } + + out.print("public class "); + out.print(builderSimpleClassName); + out.println(" {"); + out.println(); + + out.print(" private "); + out.print(simpleClassName); + out.print(" object = new "); + out.print(simpleClassName); + out.println("();"); + out.println(); + + out.print(" public "); + out.print(simpleClassName); + out.println(" build() {"); + out.println(" return object;"); + out.println(" }"); + out.println(); + + setterMap.entrySet().forEach(setter -> { + String methodName = setter.getKey(); + String argumentType = setter.getValue(); + + out.print(" public "); + out.print(builderSimpleClassName); + out.print(" "); + out.print(methodName); + + out.print("("); + + out.print(argumentType); + out.println(" value) {"); + out.print(" object."); + out.print(methodName); + out.println("(value);"); + out.println(" return this;"); + out.println(" }"); + out.println(); + }); + + out.println("}"); + + } + } + +} diff --git a/annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProperty.java b/annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProperty.java new file mode 100644 index 0000000000..84fcc73850 --- /dev/null +++ b/annotations/annotation-processing/src/main/java/com/baeldung/annotation/processor/BuilderProperty.java @@ -0,0 +1,8 @@ +package com.baeldung.annotation.processor; + +import java.lang.annotation.*; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +public @interface BuilderProperty { +} diff --git a/annotations/annotation-user/pom.xml b/annotations/annotation-user/pom.xml new file mode 100644 index 0000000000..f76f691f93 --- /dev/null +++ b/annotations/annotation-user/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + + annotations + com.baeldung + 1.0.0-SNAPSHOT + ../ + + + annotation-user + + + + + com.baeldung + annotation-processing + ${project.parent.version} + + + + junit + junit + 4.12 + test + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + + + + + \ No newline at end of file diff --git a/annotations/annotation-user/src/main/java/com/baeldung/annotation/Person.java b/annotations/annotation-user/src/main/java/com/baeldung/annotation/Person.java new file mode 100644 index 0000000000..23787ba4f4 --- /dev/null +++ b/annotations/annotation-user/src/main/java/com/baeldung/annotation/Person.java @@ -0,0 +1,29 @@ +package com.baeldung.annotation; + +import com.baeldung.annotation.processor.BuilderProperty; + +public class Person { + + private int age; + + private String name; + + public int getAge() { + return age; + } + + @BuilderProperty + public void setAge(int age) { + this.age = age; + } + + public String getName() { + return name; + } + + @BuilderProperty + public void setName(String name) { + this.name = name; + } + +} diff --git a/annotations/annotation-user/src/test/java/com/baeldung/annotation/PersonBuilderTest.java b/annotations/annotation-user/src/test/java/com/baeldung/annotation/PersonBuilderTest.java new file mode 100644 index 0000000000..72f9ac8bc7 --- /dev/null +++ b/annotations/annotation-user/src/test/java/com/baeldung/annotation/PersonBuilderTest.java @@ -0,0 +1,22 @@ +package com.baeldung.annotation; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class PersonBuilderTest { + + @Test + public void whenBuildPersonWithBuilder_thenObjectHasPropertyValues() { + + Person person = new PersonBuilder() + .setAge(25) + .setName("John") + .build(); + + assertEquals(25, person.getAge()); + assertEquals("John", person.getName()); + + } + +} diff --git a/annotations/pom.xml b/annotations/pom.xml new file mode 100644 index 0000000000..f691674cf1 --- /dev/null +++ b/annotations/pom.xml @@ -0,0 +1,20 @@ + + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + annotations + pom + + + annotation-processing + annotation-user + + + \ No newline at end of file diff --git a/core-java-8/README.md b/core-java-8/README.md index e6bac2a4c9..c130e6bd41 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -11,4 +11,14 @@ - [Lambda Expressions and Functional Interfaces: Tips and Best Practices](http://www.baeldung.com/java-8-lambda-expressions-tips) - [The Double Colon Operator in Java 8](http://www.baeldung.com/java-8-double-colon-operator) - [Java 8 Streams Advanced](http://www.baeldung.com/java-8-streams) -- [Java 8 Collectors](http://www.baeldung.com/java-8-collectors) \ No newline at end of file +- [Java 8 Collectors](http://www.baeldung.com/java-8-collectors) +- [Convert String to int or Integer in Java](http://www.baeldung.com/java-convert-string-to-int-or-integer) +- [Convert char to String in Java](http://www.baeldung.com/java-convert-char-to-string) +- [Guide to Java 8’s Functional Interfaces](http://www.baeldung.com/java-8-functional-interfaces) +- [Guide To CompletableFuture](http://www.baeldung.com/java-completablefuture) +- [Introduction to Thread Pools in Java](http://www.baeldung.com/thread-pool-java-and-guava) +- [Guide to Java 8 Collectors](http://www.baeldung.com/java-8-collectors) +- [The Java 8 Stream API Tutorial](http://www.baeldung.com/java-8-streams) +- [New Features in Java 8](http://www.baeldung.com/java-8-new-features) +- [Introduction to Java 8 Streams](http://www.baeldung.com/java-8-streams-introduction) +- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join) diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index 63df0e1b95..566eb4e43a 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -1,9 +1,10 @@ 4.0.0 + com.baeldung + 1.0.0-SNAPSHOT core-java8 - 0.1-SNAPSHOT core-java8 @@ -111,6 +112,9 @@ + + UTF-8 + 1.7.13 1.0.13 diff --git a/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeTest.java b/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeTest.java new file mode 100644 index 0000000000..06d9394a5e --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeTest.java @@ -0,0 +1,47 @@ +package com.baeldung.util; + +import static org.junit.Assert.assertEquals; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.temporal.ChronoField; +import java.util.Calendar; +import java.util.GregorianCalendar; + +import org.junit.Test; + +public class CurrentDateTimeTest { + + @Test + public void shouldReturnCurrentDate() { + + final LocalDate now = LocalDate.now(); + final Calendar calendar = GregorianCalendar.getInstance(); + + assertEquals("10-10-2010".length(), now.toString().length()); + assertEquals(calendar.get(Calendar.DATE), now.get(ChronoField.DAY_OF_MONTH)); + assertEquals(calendar.get(Calendar.MONTH), now.get(ChronoField.MONTH_OF_YEAR) - 1); + assertEquals(calendar.get(Calendar.YEAR), now.get(ChronoField.YEAR)); + } + + @Test + public void shouldReturnCurrentTime() { + + final LocalTime now = LocalTime.now(); + final Calendar calendar = GregorianCalendar.getInstance(); + + assertEquals(calendar.get(Calendar.HOUR_OF_DAY), now.get(ChronoField.HOUR_OF_DAY)); + assertEquals(calendar.get(Calendar.MINUTE), now.get(ChronoField.MINUTE_OF_HOUR)); + assertEquals(calendar.get(Calendar.SECOND), now.get(ChronoField.SECOND_OF_MINUTE)); + } + + @Test + public void shouldReturnCurrentTimestamp() { + + final Instant now = Instant.now(); + final Calendar calendar = GregorianCalendar.getInstance(); + + assertEquals(calendar.getTimeInMillis() / 1000, now.getEpochSecond()); + } +} diff --git a/core-java-8/src/test/resources/.gitignore b/core-java-8/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/core-java-8/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/core-java-8/src/test/resources/test.txt b/core-java-8/src/test/resources/test.txt new file mode 100644 index 0000000000..652d70630f --- /dev/null +++ b/core-java-8/src/test/resources/test.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse facilisis neque sed turpis venenatis, non dignissim risus volutpat. \ No newline at end of file diff --git a/core-java-9/pom.xml b/core-java-9/pom.xml index b29838d283..844ad6a782 100644 --- a/core-java-9/pom.xml +++ b/core-java-9/pom.xml @@ -60,12 +60,8 @@ 1.9 1.9 - true - - @@ -85,12 +81,7 @@ - - 3.6-jigsaw-SNAPSHOT - - + 3.6-jigsaw-SNAPSHOT 2.19.1 diff --git a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java index 102ceda18f..b0684a94f8 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java +++ b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java @@ -42,6 +42,19 @@ public class Java9OptionalsStreamTest { assertEquals("bar", filteredList.get(1)); } + @Test + public void filterOutPresentOptionalsWithFlatMap2() { + assertEquals(4, listOfOptionals.size()); + + List filteredList = listOfOptionals.stream() + .flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty)) + .collect(Collectors.toList()); + assertEquals(2, filteredList.size()); + + assertEquals("foo", filteredList.get(0)); + assertEquals("bar", filteredList.get(1)); + } + @Test public void filterOutPresentOptionalsWithJava9() { assertEquals(4, listOfOptionals.size()); diff --git a/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java b/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java index d6c16b91bc..a00646e4db 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java +++ b/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java @@ -1,6 +1,5 @@ package com.baeldung.java9; - -import static org.junit.Assert.assertTrue; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; diff --git a/core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamTest.java b/core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamTest.java new file mode 100644 index 0000000000..56b4bb7b8c --- /dev/null +++ b/core-java-9/src/test/java/com/baeldung/java9/OptionalToStreamTest.java @@ -0,0 +1,21 @@ +package com.baeldung.java9; + +import java.util.Optional; +import java.util.stream.Stream; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +public class OptionalToStreamTest { + + @Test + public void testOptionalToStream() { + Optional op = Optional.ofNullable("String value"); + Stream strOptionalStream = op.stream(); + Stream filteredStream = strOptionalStream.filter((str) -> { + return str != null && str.startsWith("String"); + }); + assertEquals(1, filteredStream.count()); + + } +} diff --git a/core-java-9/src/test/java/com/baeldung/java9/SetExamplesTest.java b/core-java-9/src/test/java/com/baeldung/java9/SetExamplesTest.java new file mode 100644 index 0000000000..0f8db83d9c --- /dev/null +++ b/core-java-9/src/test/java/com/baeldung/java9/SetExamplesTest.java @@ -0,0 +1,26 @@ +package com.baeldung.java9; + +import java.util.Set; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class SetExamplesTest { + + @Test + public void testUnmutableSet() { + Set strKeySet = Set.of("key1", "key2", "key3"); + try { + strKeySet.add("newKey"); + } catch (UnsupportedOperationException uoe) { + } + assertEquals(strKeySet.size(), 3); + } + + @Test + public void testArrayToSet() { + Integer[] intArray = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; + Set intSet = Set.of(intArray); + assertEquals(intSet.size(), intArray.length); + } +} diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java new file mode 100644 index 0000000000..d4a6a0f42e --- /dev/null +++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java @@ -0,0 +1,65 @@ +package org.baeldung.equalshashcode.entities; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class ComplexClass { + + private List genericList; + private Set integerSet; + + public ComplexClass(ArrayList genericArrayList, HashSet integerHashSet) { + super(); + this.genericList = genericArrayList; + this.integerSet = integerHashSet; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((genericList == null) ? 0 : genericList.hashCode()); + result = prime * result + ((integerSet == null) ? 0 : integerSet.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof ComplexClass)) + return false; + ComplexClass other = (ComplexClass) obj; + if (genericList == null) { + if (other.genericList != null) + return false; + } else if (!genericList.equals(other.genericList)) + return false; + if (integerSet == null) { + if (other.integerSet != null) + return false; + } else if (!integerSet.equals(other.integerSet)) + return false; + return true; + } + + protected List getGenericList() { + return genericList; + } + + protected void setGenericArrayList(List genericList) { + this.genericList = genericList; + } + + protected Set getIntegerSet() { + return integerSet; + } + + protected void setIntegerSet(Set integerSet) { + this.integerSet = integerSet; + } +} diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java similarity index 100% rename from eclipse/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java rename to core-java/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java similarity index 96% rename from eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java rename to core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java index 315ef41a12..1e1423f0b3 100644 --- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java +++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java @@ -11,13 +11,11 @@ public class Rectangle extends Shape { @Override public double area() { - // A = w * l return width * length; } @Override public double perimeter() { - // P = 2(w + l) return 2 * (width + length); } diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Shape.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Shape.java similarity index 100% rename from eclipse/src/main/java/org/baeldung/equalshashcode/entities/Shape.java rename to core-java/src/main/java/org/baeldung/equalshashcode/entities/Shape.java diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Square.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Square.java similarity index 100% rename from eclipse/src/main/java/org/baeldung/equalshashcode/entities/Square.java rename to core-java/src/main/java/org/baeldung/equalshashcode/entities/Square.java diff --git a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java b/core-java/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java similarity index 90% rename from eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java rename to core-java/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java index 09123e988b..75d96e5989 100644 --- a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java +++ b/core-java/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java @@ -22,11 +22,10 @@ public class ComplexClassTest { strArrayListD.add("pqr"); ComplexClass dObject = new ComplexClass(strArrayListD, new HashSet(45, 67)); - // equals() Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject)); - // hashCode() + Assert.assertTrue(aObject.hashCode() == bObject.hashCode()); - // non-equal objects are not equals() and have different hashCode() + Assert.assertFalse(aObject.equals(dObject)); Assert.assertFalse(aObject.hashCode() == dObject.hashCode()); } diff --git a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java b/core-java/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java similarity index 84% rename from eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java rename to core-java/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java index feb04d65ff..16f25ae021 100644 --- a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java +++ b/core-java/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java @@ -12,11 +12,10 @@ public class PrimitiveClassTest { PrimitiveClass bObject = new PrimitiveClass(false, 2); PrimitiveClass dObject = new PrimitiveClass(true, 2); - // equals() Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject)); - // hashCode() + Assert.assertTrue(aObject.hashCode() == bObject.hashCode()); - // non-equal objects are not equals() and have different hashCode() + Assert.assertFalse(aObject.equals(dObject)); Assert.assertFalse(aObject.hashCode() == dObject.hashCode()); } diff --git a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java b/core-java/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java similarity index 84% rename from eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java rename to core-java/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java index 53ca199405..52d024a696 100644 --- a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java +++ b/core-java/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java @@ -15,11 +15,10 @@ public class SquareClassTest { Square dObject = new Square(20, Color.BLUE); - // equals() Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject)); - // hashCode() + Assert.assertTrue(aObject.hashCode() == bObject.hashCode()); - // non-equal objects are not equals() and have different hashCode() + Assert.assertFalse(aObject.equals(dObject)); Assert.assertFalse(aObject.hashCode() == dObject.hashCode()); } diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java deleted file mode 100644 index 3f7723facd..0000000000 --- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.baeldung.equalshashcode.entities; - -import java.util.ArrayList; -import java.util.HashSet; - -public class ComplexClass { - - private ArrayList genericArrayList; - private HashSet integerHashSet; - - public ComplexClass(ArrayList genericArrayList, HashSet integerHashSet) { - super(); - this.genericArrayList = genericArrayList; - this.integerHashSet = integerHashSet; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((genericArrayList == null) ? 0 : genericArrayList.hashCode()); - result = prime * result + ((integerHashSet == null) ? 0 : integerHashSet.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof ComplexClass)) - return false; - ComplexClass other = (ComplexClass) obj; - if (genericArrayList == null) { - if (other.genericArrayList != null) - return false; - } else if (!genericArrayList.equals(other.genericArrayList)) - return false; - if (integerHashSet == null) { - if (other.integerHashSet != null) - return false; - } else if (!integerHashSet.equals(other.integerHashSet)) - return false; - return true; - } - - protected ArrayList getGenericArrayList() { - return genericArrayList; - } - - protected void setGenericArrayList(ArrayList genericArrayList) { - this.genericArrayList = genericArrayList; - } - - protected HashSet getIntegerHashSet() { - return integerHashSet; - } - - protected void setIntegerHashSet(HashSet integerHashSet) { - this.integerHashSet = integerHashSet; - } -} diff --git a/pom.xml b/pom.xml index 33162777b7..37ed734567 100644 --- a/pom.xml +++ b/pom.xml @@ -132,6 +132,7 @@ wicket xstream java-cassandra + annotations diff --git a/spring-data-neo4j/README.md b/spring-data-neo4j/README.md index e62c69f8b9..0f13d9dbc9 100644 --- a/spring-data-neo4j/README.md +++ b/spring-data-neo4j/README.md @@ -1,7 +1,7 @@ ## Spring Data Neo4j ### Relevant Articles: -- [Introduction to Spring Data Neo4j](http://www.baeldung.com/spring-data-neo4j-tutorial) +- [Introduction to Spring Data Neo4j](http://www.baeldung.com/spring-data-neo4j-intro) ### Build the Project with Tests Running ```