Skip to content

Commit 20062fa

Browse files
committedMay 3, 2017
All without Readme and pumlid
1 parent 8530d01 commit 20062fa

File tree

8 files changed

+147
-0
lines changed

8 files changed

+147
-0
lines changed
 

‎marker/etc/MarkerDiagram.png

6.31 KB
Loading

‎marker/etc/MarkerDiagram.ucls

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.2.0" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
4+
<class id="1" language="java" name="Guard" project="marker" file="/marker/src/main/java/Guard.java" binary="false"
5+
corner="BOTTOM_RIGHT">
6+
<position height="-1" width="-1" x="416" y="348"/>
7+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10+
<operations public="true" package="true" protected="true" private="true" static="true"/>
11+
</display>
12+
</class>
13+
<interface id="2" language="java" name="Permission" project="marker" file="/marker/src/main/java/Permission.java"
14+
binary="false" corner="BOTTOM_RIGHT">
15+
<position height="-1" width="-1" x="261" y="175"/>
16+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
17+
sort-features="false" accessors="true" visibility="true">
18+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
19+
<operations public="true" package="true" protected="true" private="true" static="true"/>
20+
</display>
21+
</interface>
22+
<class id="3" language="java" name="Thief" project="marker" file="/marker/src/main/java/Thief.java" binary="false"
23+
corner="BOTTOM_RIGHT">
24+
<position height="-1" width="-1" x="236" y="355"/>
25+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
26+
sort-features="false" accessors="true" visibility="true">
27+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
28+
<operations public="true" package="true" protected="true" private="true" static="true"/>
29+
</display>
30+
</class>
31+
<realization id="4">
32+
<end type="SOURCE" refId="1"/>
33+
<end type="TARGET" refId="2"/>
34+
</realization>
35+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
36+
sort-features="false" accessors="true" visibility="true">
37+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
38+
<operations public="true" package="true" protected="true" private="true" static="true"/>
39+
</classifier-display>
40+
<association-display labels="true" multiplicity="true"/>
41+
</class-diagram>

‎marker/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>marker</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.junit.jupiter</groupId>
16+
<artifactId>junit-jupiter-api</artifactId>
17+
<version>RELEASE</version>
18+
</dependency>
19+
<dependency>
20+
<groupId>junit</groupId>
21+
<artifactId>junit</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>junit</groupId>
25+
<artifactId>junit</artifactId>
26+
</dependency>
27+
</dependencies>
1328

1429

1530
</project>

‎marker/src/main/java/App.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
11
/**
22
* Created by Alexis on 28-Apr-17.
3+
* With Marker interface idea is to make empty interface and extend it.
4+
* Basically it is just to identify the special objects from normal objects.
5+
* Like in case of serialization , objects that need to be serialized must implement serializable interface
6+
* (it is empty interface) and down the line writeObject() method must be checking
7+
* if it is a instance of serializable or not.
8+
* <p>
9+
* Marker interface vs annotation
10+
* Marker interfaces and marker annotations both have their uses,
11+
* neither of them is obsolete or always better then the other one.
12+
* If you want to define a type that does not have any new methods associated with it,
13+
* a marker interface is the way to go.
14+
* If you want to mark program elements other than classes and interfaces,
15+
* to allow for the possibility of adding more information to the marker in the future,
16+
* or to fit the marker into a framework that already makes heavy use of annotation types,
17+
* then a marker annotation is the correct choice
318
*/
419
public class App {
20+
21+
/**
22+
* Program entry point
23+
*
24+
* @param args command line args
25+
*/
526
public static void main(String[] args) {
27+
628
Guard guard = new Guard();
29+
Thief thief = new Thief();
730

831
if (guard instanceof Permission) {
932
guard.enter();
33+
} else {
34+
System.out.println("You have no permission to enter, please leave this area");
35+
}
36+
37+
if (thief instanceof Permission) {
38+
thief.steal();
39+
} else {
40+
thief.doNothing();
1041
}
1142
}
1243
}

‎marker/src/main/java/Thief.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Created by Alexis on 02-May-17.
3+
*/
4+
public class Thief {
5+
protected static void steal() {
6+
System.out.println("Steal valuable items");
7+
}
8+
9+
protected static void doNothing() {
10+
System.out.println("Pretend nothing happened and just leave");
11+
}
12+
}

‎marker/src/test/java/AppTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Created by Alexis on 01-May-17.
3+
*/
4+
5+
import org.junit.Test;
6+
7+
/**
8+
* Application test
9+
*/
10+
public class AppTest {
11+
12+
@Test
13+
public void test() {
14+
String[] args = {};
15+
App.main(args);
16+
}
17+
}

‎marker/src/test/java/GuardTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import org.junit.Test;
2+
3+
import static org.hamcrest.CoreMatchers.instanceOf;
4+
import static org.junit.Assert.assertThat;
5+
6+
/**
7+
* Created by Alexis on 02-May-17.
8+
*/
9+
public class GuardTest {
10+
11+
@Test
12+
public void testGuard() {
13+
Guard guard = new Guard();
14+
assertThat(guard, instanceOf(Permission.class));
15+
}
16+
}

‎marker/src/test/java/ThiefTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Created by Alexis on 02-May-17.
3+
*/
4+
5+
import org.junit.Test;
6+
7+
import static org.junit.Assert.assertFalse;
8+
9+
public class ThiefTest {
10+
@Test
11+
public void testGuard() {
12+
Thief thief = new Thief();
13+
assertFalse(thief instanceof Permission);
14+
}
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.