docs: add marker explanation (#2945)

This commit is contained in:
Ilkka Seppälä
2024-05-07 14:23:06 +03:00
committed by GitHub
parent 3c7b3d99cc
commit a3b582f993
2 changed files with 115 additions and 13 deletions
+3 -3
View File
@@ -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