Annotation Interface

@Retention(RetentionPolicy.RUNTIME)
@target({ElementType.TYPE, ElementType.Method})
@interface CustomAnno{
int var0() default 0;
String var1() default "custom";
}
  1. var0, var1 are variables /attributes / elements.( primitive data types and the array can be used)
  2. @retention → Availability of the annotation.
  3. @target → The target Java elements where the annotation can be added(Method, Package, parameter and etc)

Logic Class

@Aspect
@Component
public CustomAnnoLogicImplementation{
@Around("@annotation(com.rcvaram.annotation.CustomAnno)")
public Object implementLogic(ProceedingJointPoint point){
//Logic1 before executing the point
Object obj = point.proceed();
// Logic2 After executing the point
retun obj;
}
}

Implementation

public class Test{

@CustomAnno(var0=5, var1="testing")
public void test(){
//Some Logic
}
}

CustomTimeTracker Annotation

S → Single Responsibility Principle

Every class must perform a single functionality.

O → Open & Close Principle

Open for Extension & Closed for Modification

L → Liskov Substitution Principle

Parent class can be…

Sivaram Rasathurai

Software Engineer — Sysco LABS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store