Skip to content

Commit f2e35ec

Browse files
committed
iluwatar#567 fix version and javadoc
1 parent 1abd96a commit f2e35ec

File tree

9 files changed

+33
-31
lines changed

9 files changed

+33
-31
lines changed

marker/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ tags:
1010
---
1111

1212
## Intent
13-
Using empy interfaces as markers to distinguish special treated objects.
13+
Using empty interfaces as markers to distinguish special treated objects.
1414

1515
![alt text](./etc/MarkerDiagram.png "Marker Interface")
1616

1717
## Applicability
1818
Use the Marker Interface pattern when
1919

20-
* you want to identify the special objects from normal objects
21-
* define a type that is implemented by instances of the marked class, marker annotations can not do that
20+
* you want to identify the special objects from normal objects (to treat them differently)
21+
* you want to mark that some object is available for certain sort of operations
2222

2323
## Real world examples
2424

25-
* [javase.7.docs.api.java.io.Serializable](https://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html)
26-
* [javase.7.docs.api.java.lang.Cloneable](https://docs.oracle.com/javase/7/docs/api/java/lang/Cloneable.html)
25+
* [javase.8.docs.api.java.io.Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html)
26+
* [javase.8.docs.api.java.lang.Cloneable](https://docs.oracle.com/javase/8/docs/api/java/lang/Cloneable.html)
2727

2828
## Credits
2929

marker/pom.xml

+1-9
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,10 @@
3030

3131
<artifactId>marker</artifactId>
3232
<dependencies>
33-
<dependency>
34-
<groupId>org.junit.jupiter</groupId>
35-
<artifactId>junit-jupiter-api</artifactId>
36-
<version>RELEASE</version>
37-
</dependency>
38-
<dependency>
39-
<groupId>junit</groupId>
40-
<artifactId>junit</artifactId>
41-
</dependency>
4233
<dependency>
4334
<groupId>junit</groupId>
4435
<artifactId>junit</artifactId>
36+
<scope>test</scope>
4537
</dependency>
4638
</dependencies>
4739

marker/src/main/java/App.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.slf4j.Logger;
2+
import org.slf4j.LoggerFactory;
3+
14
/**
25
* Created by Alexis on 28-Apr-17.
36
* With Marker interface idea is to make empty interface and extend it.
@@ -25,13 +28,14 @@ public class App {
2528
*/
2629
public static void main(String[] args) {
2730

31+
final Logger logger = LoggerFactory.getLogger(App.class);
2832
Guard guard = new Guard();
2933
Thief thief = new Thief();
3034

3135
if (guard instanceof Permission) {
3236
guard.enter();
3337
} else {
34-
System.out.println("You have no permission to enter, please leave this area");
38+
logger.info("You have no permission to enter, please leave this area");
3539
}
3640

3741
if (thief instanceof Permission) {

marker/src/main/java/Guard.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import org.slf4j.Logger;
2+
import org.slf4j.LoggerFactory;
3+
14
/**
2-
* Created by Alexis on 29-Apr-17.
5+
* Class defining Guard
36
*/
47
public class Guard implements Permission {
58

9+
private static final Logger LOGGER = LoggerFactory.getLogger(Guard.class);
10+
611
protected static void enter() {
7-
System.out.println("You can enter");
8-
}
912

13+
LOGGER.info("You can enter");
14+
}
1015
}

marker/src/main/java/Permission.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/**
2-
* Created by Alexis on 29-Apr-17.
32
* Interface without any methods
43
* Marker interface is based on that assumption
54
*/

marker/src/main/java/Thief.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import org.slf4j.Logger;
2+
import org.slf4j.LoggerFactory;
3+
14
/**
2-
* Created by Alexis on 02-May-17.
5+
* Class defining Thief
36
*/
47
public class Thief {
8+
9+
private static final Logger LOGGER = LoggerFactory.getLogger(Thief.class);
10+
511
protected static void steal() {
6-
System.out.println("Steal valuable items");
12+
LOGGER.info("Steal valuable items");
713
}
814

915
protected static void doNothing() {
10-
System.out.println("Pretend nothing happened and just leave");
16+
LOGGER.info("Pretend nothing happened and just leave");
1117
}
1218
}

marker/src/test/java/AppTest.java

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* Created by Alexis on 01-May-17.
3-
*/
4-
51
import org.junit.Test;
62

73
/**

marker/src/test/java/GuardTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import static org.junit.Assert.assertThat;
55

66
/**
7-
* Created by Alexis on 02-May-17.
7+
* Guard test
88
*/
99
public class GuardTest {
1010

@@ -13,4 +13,4 @@ public void testGuard() {
1313
Guard guard = new Guard();
1414
assertThat(guard, instanceOf(Permission.class));
1515
}
16-
}
16+
}

marker/src/test/java/ThiefTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import static org.junit.Assert.assertFalse;
44

55
/**
6-
* Created by Alexis on 02-May-17.
6+
* Thief test
77
*/
88
public class ThiefTest {
99
@Test
10-
public void testGuard() {
10+
public void testThief() {
1111
Thief thief = new Thief();
1212
assertFalse(thief instanceof Permission);
1313
}
14-
}
14+
}

0 commit comments

Comments
 (0)