Skip to content

Instantly share code, notes, and snippets.

@ajinzrathod
Last active July 28, 2021 06:43
Show Gist options
  • Save ajinzrathod/b7b5d7dd880e92f1022ff88e0c265d38 to your computer and use it in GitHub Desktop.
Save ajinzrathod/b7b5d7dd880e92f1022ff88e0c265d38 to your computer and use it in GitHub Desktop.
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