diff --git a/.current.json b/.current.json index 451b603..498c459 100644 --- a/.current.json +++ b/.current.json @@ -1 +1 @@ -{"assignment":"java-spring-ru/first-start"} +{"assignment":"java-spring-ru/annotations"} diff --git a/java-spring-ru/annotations/gradlew b/java-spring-ru/annotations/gradlew old mode 100644 new mode 100755 diff --git a/java-spring-ru/annotations/src/main/java/exercise/Application.java b/java-spring-ru/annotations/src/main/java/exercise/Application.java index c2e0363..9e7b579 100644 --- a/java-spring-ru/annotations/src/main/java/exercise/Application.java +++ b/java-spring-ru/annotations/src/main/java/exercise/Application.java @@ -1,23 +1,23 @@ -package exercise; - -import exercise.model.Address; -import exercise.annotation.Inspect; -import java.lang.reflect.Method; - -public class Application { - public static void main(String[] args) { - var address = new Address("London", 12345678); - - // BEGIN - for (var method : Address.class.getDeclaredMethods()) { - if (method.isAnnotationPresent(Inspect.class)) { - String result = "Method " + - method.getName() + - " returns a value of type " + - method.getReturnType().getSimpleName(); - System.out.println(result); - } - } - // END - } -} +package exercise; + +import exercise.model.Address; +import exercise.annotation.Inspect; +import java.lang.reflect.Method; + +public class Application { + public static void main(String[] args) { + var address = new Address("London", 12345678); + + // BEGIN + for (var method : Address.class.getDeclaredMethods()) { + if (method.isAnnotationPresent(Inspect.class)) { + String result = "Method " + + method.getName() + + " returns a value of type " + + method.getReturnType().getSimpleName(); + System.out.println(result); + } + } + // END + } +} diff --git a/java-spring-ru/annotations/src/main/java/exercise/annotation/Inspect.java b/java-spring-ru/annotations/src/main/java/exercise/annotation/Inspect.java index 9090bee..c4d5f77 100644 --- a/java-spring-ru/annotations/src/main/java/exercise/annotation/Inspect.java +++ b/java-spring-ru/annotations/src/main/java/exercise/annotation/Inspect.java @@ -1,14 +1,14 @@ -package exercise.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -// BEGIN -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Inspect { - -} -// END +package exercise.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +// BEGIN +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Inspect { + +} +// END diff --git a/java-spring-ru/annotations/src/main/java/exercise/model/Address.java b/java-spring-ru/annotations/src/main/java/exercise/model/Address.java index d8b7a37..22743c3 100644 --- a/java-spring-ru/annotations/src/main/java/exercise/model/Address.java +++ b/java-spring-ru/annotations/src/main/java/exercise/model/Address.java @@ -1,31 +1,31 @@ -package exercise.model; - -import exercise.annotation.Inspect; - -public class Address { - private String city; - private int postalCode; - - public Address(String city, int postalCode) { - this.city = city; - this.postalCode = postalCode; - } - - // BEGIN - @Inspect - // END - public String getCity() { - return city; - } - - // BEGIN - @Inspect - // END - public int getPostalCode() { - return postalCode; - } - - public String getFullAddress() { - return city + " " + postalCode; - } -} +package exercise.model; + +import exercise.annotation.Inspect; + +public class Address { + private String city; + private int postalCode; + + public Address(String city, int postalCode) { + this.city = city; + this.postalCode = postalCode; + } + + // BEGIN + @Inspect + // END + public String getCity() { + return city; + } + + // BEGIN + @Inspect + // END + public int getPostalCode() { + return postalCode; + } + + public String getFullAddress() { + return city + " " + postalCode; + } +}