I know marker interface in java. It is used to define a specific behaviour about a class. For example, Serializable interface has the specific ability to store an object into by
ObjectOutputStream and ObjectInputStream will check your class whether or not it implementes Serializable, Externalizable. If yes it will continue or else will thrown NonSerializableException.
Create an interface without any method and that is your marker interface.
Sample
public interface IMarkerEntity {
}
If any class which implement this interface will be taken as database entity by your application.
Sample Code:
public boolean save(Object object) throws InvalidEntityException {
if(!(object instanceof IMarkerEntity)) {
throw new InvalidEntityException("Invalid Entity Found, cannot proceed");
}
database.save(object);
}
The whole idea of Marker Interface Pattern is to provide a mean to say "yes I am something" and then system will proceed with the default process, like when you mark your class as Serialzable it just tells that this class can be converted to bytes.