![JAR search and dependency download from the Maven repository](/logo.png)
at.chrl.callbacks.Callback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chrl-callbacks Show documentation
Show all versions of chrl-callbacks Show documentation
Callback Framework to hook up on method calls with annotations
/**
* This file is part of aion-lightning .
*
* aion-lightning is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* aion-lightning is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* aion-lightning. If not, see .
*/
package at.chrl.callbacks;
/**
* Basic callback class.
* Each enhanced method will call "beforeCall" and "afterCall" methods
*
* @author SoulKeeper
*/
@SuppressWarnings("rawtypes")
public interface Callback {
/**
* Method that is called before actual method is invoked.
*
* Callback should return one of the following results:
*
* - {@link CallbackResult#newContinue()}
* - {@link CallbackResult#newCallbackBlocker()}
* - {@link CallbackResult#newFullBlocker(Object)}
*
*
* if result is not {@link CallbackResult#newFullBlocker(Object)} then
* method will be executed normally. In other case
* {@link CallbackResult#getResult()} will be returned.
*
* @param obj
* on whom method should be invoked
* @param args
* method args
* @return see {@link CallbackResult}
*/
public default CallbackResult beforeCall(T obj, Object[] args) {
return CallbackResult.newContinue();
}
/**
* Method that is called after actual method call.
*
* Callback should return one of the following results:
*
* - {@link CallbackResult#newContinue()}
* - {@link CallbackResult#newCallbackBlocker()}
* - {@link CallbackResult#newFullBlocker(Object)}
*
*
* if result is not {@link CallbackResult#newFullBlocker(Object)} then
* mehodResult will return unmodified. In other case
* {@link CallbackResult#getResult()} will be returned.
*
* @param obj
* on whom method was called
* @param args
* method args
* @param methodResult
* result of method invocation
* @return see {@link CallbackResult}
*/
public default CallbackResult afterCall(T obj, Object[] args, Object methodResult) {
return CallbackResult.newContinue();
}
/**
* Returns base class that will be used as callback identificator.
* {@link at.chrl.callbacks.metadata.ObjectCallback#value()} should contain
* class that will be invoked
*
* @return base class of callback
*/
@SuppressWarnings("unchecked")
public default Class extends Callback>> getBaseClass() {
return (Class extends Callback>>) this.getClass();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy