I have two aspects which are going to perform some validation. The aspects intercept all methods annotated with @NotNull
and @IsUnique
annotations. For instance:
@NotNull
@IsUnique
public void save(Player p){
// persisting
}
Aspects:
public aspect NotNullInterceptor{
pointcut NotNull(): execution(public * (@NotNull *).*(..));
before() : NotNull() {
//Validation and handling
}
}
public aspect IsUniqueInterceptor{
pointcut IsUnuque(): execution(public * (@IsUnique *).*(..));
before() : IsUnuque() {
//Validation and handling
}
}
The thing is I need to perform NotNull
validation strictly before IsUnique
validation to avoid throwing NullPointerException
.
Is it reliable if I put @NotNull
annotation before @IsUnique
annotation?