2017-05-03 19:48:29 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Marker Interface
|
|
|
|
folder: marker
|
|
|
|
permalink: /patterns/marker/
|
2019-12-13 21:09:28 +02:00
|
|
|
categories: Structural
|
2021-05-19 10:49:05 -06:00
|
|
|
language: en
|
2017-05-03 19:48:29 +02:00
|
|
|
tags:
|
2019-12-13 21:09:28 +02:00
|
|
|
- Decoupling
|
2017-05-03 19:48:29 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
## Intent
|
2017-05-23 01:38:02 +02:00
|
|
|
Using empty interfaces as markers to distinguish special treated objects.
|
2017-05-03 19:48:29 +02:00
|
|
|
|
2019-12-07 20:01:13 +02:00
|
|
|
## Class diagram
|
2017-05-03 19:49:25 +02:00
|
|
|

|
2017-05-03 19:48:29 +02:00
|
|
|
|
|
|
|
## Applicability
|
|
|
|
Use the Marker Interface pattern when
|
|
|
|
|
2017-05-23 01:38:02 +02:00
|
|
|
* you want to identify the special objects from normal objects (to treat them differently)
|
|
|
|
* you want to mark that some object is available for certain sort of operations
|
2017-05-03 19:48:29 +02:00
|
|
|
|
|
|
|
## Real world examples
|
|
|
|
|
2017-05-23 01:38:02 +02:00
|
|
|
* [javase.8.docs.api.java.io.Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html)
|
|
|
|
* [javase.8.docs.api.java.lang.Cloneable](https://docs.oracle.com/javase/8/docs/api/java/lang/Cloneable.html)
|
2017-05-03 19:48:29 +02:00
|
|
|
|
|
|
|
## Credits
|
|
|
|
|
2020-07-06 13:31:07 +03:00
|
|
|
* [Effective Java](https://www.amazon.com/gp/product/0134685997/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0134685997&linkCode=as2&tag=javadesignpat-20&linkId=4e349f4b3ff8c50123f8147c828e53eb)
|