![JAR search and dependency download from the Maven repository](/logo.png)
net.sf.esfinge.gamification.processors.RemovePointsToParameterProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gamification Show documentation
Show all versions of gamification Show documentation
The Esfinge Gamification is a matadata based framework applicable to systems requiring an gamification logic, regardless of the domain.
package net.sf.esfinge.gamification.processors;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.beanutils.PropertyUtils;
import net.sf.esfinge.gamification.achievement.Point;
import net.sf.esfinge.gamification.annotation.RemovePointsToParam;
import net.sf.esfinge.gamification.mechanics.Game;
import net.sf.esfinge.gamification.utils.ReflectionUtils;
public class RemovePointsToParameterProcessor implements AchievementProcessor {
private int quantity;
private String name;
private String parameterName;
private String propertyName;
@Override
public void receiveAnnotation(Annotation an) {
RemovePointsToParam rptu = (RemovePointsToParam) an;
quantity = rptu.quantity();
name = rptu.name();
parameterName = rptu.param();
propertyName = rptu.prop();
}
@Override
public void process(Game game, Object encapsulated, Method method,
Object[] args) {
int index = ReflectionUtils.findParameterNamed(method, parameterName);
Object target = args[index];
if(!propertyName.equals("")){
try{
target = PropertyUtils.getProperty(target, propertyName);
} catch (IllegalAccessException | InvocationTargetException
| NoSuchMethodException e){
throw new RuntimeException("Cannot retrieve property '"+propertyName+"' from class "+target.getClass(), e);
}
}
Point p = new Point(quantity, name);
game.removeAchievement(target, p);
}
@Override
public void process(Game game, Object encapsulated,
Class extends Method> class1, Object[] args) {
// TODO Auto-generated method stub
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy