Last active
July 28, 2021 06:43
-
-
Save ajinzrathod/b7b5d7dd880e92f1022ff88e0c265d38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.annotation.*; | |
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.TYPE) | |
@Inherited | |
@interface Deletable { | |
} | |
@Deletable | |
class Entity { | |
// implementation details | |
} | |
class ShapeDao extends Entity{ | |
// other dao methods | |
boolean delete(Object object) { | |
if (!(object instanceof Deletable)) { | |
return false; | |
} | |
// delete implementation details | |
return true; | |
} | |
} | |
public class UsingAnnotations { | |
public static void main(String[] args) { | |
ShapeDao sd = new ShapeDao(); | |
System.out.println(sd.delete(sd)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment