From 082ba22f0acdd3c3ab7b6a81dbec0215567879a4 Mon Sep 17 00:00:00 2001 From: "INDUSTRYPEOPLE\\jihm" Date: Thu, 16 Nov 2017 15:35:03 -0600 Subject: [PATCH 1/4] BAEL-1068 - Javadoc example classes --- core-java/pom.xml | 10 ++- .../java/com/baeldung/javadoc/Person.java | 22 ++++++ .../java/com/baeldung/javadoc/SuperHero.java | 72 +++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 core-java/src/main/java/com/baeldung/javadoc/Person.java create mode 100644 core-java/src/main/java/com/baeldung/javadoc/SuperHero.java diff --git a/core-java/pom.xml b/core-java/pom.xml index dbf61c3acf28..e0affcdfe4fd 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -235,7 +235,15 @@ - + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0-M1 + + 1.8 + 1.8 + + org.apache.maven.plugins maven-compiler-plugin diff --git a/core-java/src/main/java/com/baeldung/javadoc/Person.java b/core-java/src/main/java/com/baeldung/javadoc/Person.java new file mode 100644 index 000000000000..5efb410de402 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/javadoc/Person.java @@ -0,0 +1,22 @@ +package com.baeldung.javadoc; + +public class Person { + /** + * This is a first name + */ + private String firstName; + private String lastName; + + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java b/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java new file mode 100644 index 000000000000..a1bb8a4a0b3c --- /dev/null +++ b/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java @@ -0,0 +1,72 @@ +package com.baeldung.javadoc; + +/** + * Hero is the main entity we will be using to . . . + * @author Captain America + * + */ +public class SuperHero extends Person { + + /** + * The public name of a hero that is common knowledge + */ + private String heroName; + private String uniquePower; + private int health; + private int defense; + + /** + *

The amount of damage prior to damage mitigation. Whether or not. . . + * Superman! + *

+ *

+ * Lorem ipsum dolor sit amet, consectetur. . . + *

+ * @param incomingDamage the amount of incoming damage + * @param damageType the value of the type of incoming damage + * @return the amount of health hero has after attack + * @see HERO-402 + * @since 1.0 + */ + public int successfullyAttacked(int incomingDamage, String damageType) { + // 2 defense points will block 1 point of damage + health = Math.max(0, health - (incomingDamage - defense/2)); + if ("fire".equals(damageType)) { + health = Math.max(0, health - 5); + } + return health; + } + + public String getHeroName() { + return heroName; + } + + public void setHeroName(String heroName) { + this.heroName = heroName; + } + + public String getUniquePower() { + return uniquePower; + } + + public void setUniquePower(String uniquePower) { + this.uniquePower = uniquePower; + } + + public int getHealth() { + return health; + } + + public void setHealth(int health) { + this.health = health; + } + + public int getDefense() { + return defense; + } + + public void setDefense(int defense) { + this.defense = defense; + } + +} From 6e6826329a3f1c29244dfed17410b01af56a0e76 Mon Sep 17 00:00:00 2001 From: Jonathan Ihm Date: Thu, 16 Nov 2017 19:35:22 -0600 Subject: [PATCH 2/4] BAEL-1068 - Formatting change for pom.xml --- core-java/pom.xml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index e0affcdfe4fd..0f10992b176f 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -235,15 +235,7 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.0-M1 - - 1.8 - 1.8 - - + org.apache.maven.plugins maven-compiler-plugin @@ -393,6 +385,16 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0-M1 + + 1.8 + 1.8 + + From 5fc964e5a2a1b3f182dda7fab6d8200bb5d487c9 Mon Sep 17 00:00:00 2001 From: Jonathan Ihm Date: Sat, 30 Dec 2017 21:18:43 -0600 Subject: [PATCH 3/4] Updated javadoc comments to reflect article example --- .../main/java/com/baeldung/javadoc/SuperHero.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java b/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java index a1bb8a4a0b3c..029a779cdb81 100644 --- a/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java +++ b/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java @@ -16,25 +16,17 @@ public class SuperHero extends Person { private int defense; /** - *

The amount of damage prior to damage mitigation. Whether or not. . . + *

This is a simple description of the method. . . * Superman! *

- *

- * Lorem ipsum dolor sit amet, consectetur. . . - *

* @param incomingDamage the amount of incoming damage - * @param damageType the value of the type of incoming damage * @return the amount of health hero has after attack * @see HERO-402 * @since 1.0 */ public int successfullyAttacked(int incomingDamage, String damageType) { - // 2 defense points will block 1 point of damage - health = Math.max(0, health - (incomingDamage - defense/2)); - if ("fire".equals(damageType)) { - health = Math.max(0, health - 5); - } - return health; + // do things + return 0; } public String getHeroName() { From 2f6dc3b294c7d57784d5f121841127613a31e004 Mon Sep 17 00:00:00 2001 From: Jonathan Ihm Date: Thu, 18 Jan 2018 19:23:40 -0600 Subject: [PATCH 4/4] Added javadoc tags for throws, deprecated, and version and a clause to throw an exception --- .../src/main/java/com/baeldung/javadoc/SuperHero.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java b/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java index 029a779cdb81..561430f66fd2 100644 --- a/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java +++ b/core-java/src/main/java/com/baeldung/javadoc/SuperHero.java @@ -23,9 +23,15 @@ public class SuperHero extends Person { * @return the amount of health hero has after attack * @see HERO-402 * @since 1.0 + * @deprecated As of version 1.1, use . . . instead + * @version 1.2 + * @throws IllegalArgumentException if incomingDamage is negative */ - public int successfullyAttacked(int incomingDamage, String damageType) { + public int successfullyAttacked(int incomingDamage, String damageType) throws Exception { // do things + if (incomingDamage < 0) { + throw new IllegalArgumentException ("Cannot cause negative damage"); + } return 0; }