All without Readme and pumlid
This commit is contained in:
parent
8530d01e10
commit
20062faae6
BIN
marker/etc/MarkerDiagram.png
Normal file
BIN
marker/etc/MarkerDiagram.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
41
marker/etc/MarkerDiagram.ucls
Normal file
41
marker/etc/MarkerDiagram.ucls
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<class-diagram version="1.2.0" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
|
||||||
|
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
|
||||||
|
<class id="1" language="java" name="Guard" project="marker" file="/marker/src/main/java/Guard.java" binary="false"
|
||||||
|
corner="BOTTOM_RIGHT">
|
||||||
|
<position height="-1" width="-1" x="416" y="348"/>
|
||||||
|
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||||
|
sort-features="false" accessors="true" visibility="true">
|
||||||
|
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
</display>
|
||||||
|
</class>
|
||||||
|
<interface id="2" language="java" name="Permission" project="marker" file="/marker/src/main/java/Permission.java"
|
||||||
|
binary="false" corner="BOTTOM_RIGHT">
|
||||||
|
<position height="-1" width="-1" x="261" y="175"/>
|
||||||
|
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||||
|
sort-features="false" accessors="true" visibility="true">
|
||||||
|
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
</display>
|
||||||
|
</interface>
|
||||||
|
<class id="3" language="java" name="Thief" project="marker" file="/marker/src/main/java/Thief.java" binary="false"
|
||||||
|
corner="BOTTOM_RIGHT">
|
||||||
|
<position height="-1" width="-1" x="236" y="355"/>
|
||||||
|
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||||
|
sort-features="false" accessors="true" visibility="true">
|
||||||
|
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
</display>
|
||||||
|
</class>
|
||||||
|
<realization id="4">
|
||||||
|
<end type="SOURCE" refId="1"/>
|
||||||
|
<end type="TARGET" refId="2"/>
|
||||||
|
</realization>
|
||||||
|
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||||
|
sort-features="false" accessors="true" visibility="true">
|
||||||
|
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||||
|
</classifier-display>
|
||||||
|
<association-display labels="true" multiplicity="true"/>
|
||||||
|
</class-diagram>
|
@ -10,6 +10,21 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>marker</artifactId>
|
<artifactId>marker</artifactId>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,12 +1,43 @@
|
|||||||
/**
|
/**
|
||||||
* Created by Alexis on 28-Apr-17.
|
* Created by Alexis on 28-Apr-17.
|
||||||
|
* With Marker interface idea is to make empty interface and extend it.
|
||||||
|
* Basically it is just to identify the special objects from normal objects.
|
||||||
|
* Like in case of serialization , objects that need to be serialized must implement serializable interface
|
||||||
|
* (it is empty interface) and down the line writeObject() method must be checking
|
||||||
|
* if it is a instance of serializable or not.
|
||||||
|
* <p>
|
||||||
|
* Marker interface vs annotation
|
||||||
|
* Marker interfaces and marker annotations both have their uses,
|
||||||
|
* neither of them is obsolete or always better then the other one.
|
||||||
|
* If you want to define a type that does not have any new methods associated with it,
|
||||||
|
* a marker interface is the way to go.
|
||||||
|
* If you want to mark program elements other than classes and interfaces,
|
||||||
|
* to allow for the possibility of adding more information to the marker in the future,
|
||||||
|
* or to fit the marker into a framework that already makes heavy use of annotation types,
|
||||||
|
* then a marker annotation is the correct choice
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Program entry point
|
||||||
|
*
|
||||||
|
* @param args command line args
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Guard guard = new Guard();
|
Guard guard = new Guard();
|
||||||
|
Thief thief = new Thief();
|
||||||
|
|
||||||
if (guard instanceof Permission) {
|
if (guard instanceof Permission) {
|
||||||
guard.enter();
|
guard.enter();
|
||||||
|
} else {
|
||||||
|
System.out.println("You have no permission to enter, please leave this area");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thief instanceof Permission) {
|
||||||
|
thief.steal();
|
||||||
|
} else {
|
||||||
|
thief.doNothing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
marker/src/main/java/Thief.java
Normal file
12
marker/src/main/java/Thief.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Created by Alexis on 02-May-17.
|
||||||
|
*/
|
||||||
|
public class Thief {
|
||||||
|
protected static void steal() {
|
||||||
|
System.out.println("Steal valuable items");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void doNothing() {
|
||||||
|
System.out.println("Pretend nothing happened and just leave");
|
||||||
|
}
|
||||||
|
}
|
17
marker/src/test/java/AppTest.java
Normal file
17
marker/src/test/java/AppTest.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* Created by Alexis on 01-May-17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application test
|
||||||
|
*/
|
||||||
|
public class AppTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
String[] args = {};
|
||||||
|
App.main(args);
|
||||||
|
}
|
||||||
|
}
|
16
marker/src/test/java/GuardTest.java
Normal file
16
marker/src/test/java/GuardTest.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Alexis on 02-May-17.
|
||||||
|
*/
|
||||||
|
public class GuardTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGuard() {
|
||||||
|
Guard guard = new Guard();
|
||||||
|
assertThat(guard, instanceOf(Permission.class));
|
||||||
|
}
|
||||||
|
}
|
15
marker/src/test/java/ThiefTest.java
Normal file
15
marker/src/test/java/ThiefTest.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Created by Alexis on 02-May-17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
|
public class ThiefTest {
|
||||||
|
@Test
|
||||||
|
public void testGuard() {
|
||||||
|
Thief thief = new Thief();
|
||||||
|
assertFalse(thief instanceof Permission);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user