mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 06:58:41 +00:00
docs: add marker explanation (#2945)
This commit is contained in:
@@ -22,18 +22,18 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* empty interface) and down the line writeObject() method must be checking if it is an 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
|
||||
* neither of them is obsolete or always better than 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
|
||||
|
||||
Reference in New Issue
Block a user