
net.cassite.pure.ioc.handlers.param.ParamForceHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pure.ioc Show documentation
Show all versions of pure.ioc Show documentation
Lightweight type and annotation based dependency injection framework
The newest version!
package net.cassite.pure.ioc.handlers.param;
import java.lang.annotation.Annotation;
import java.util.Map;
import net.cassite.pure.ioc.AnnotationHandlingException;
import net.cassite.pure.ioc.IOCController;
import net.cassite.pure.ioc.Scope;
import net.cassite.pure.ioc.annotations.Force;
import net.cassite.pure.ioc.handlers.IrrelevantAnnotationHandlingException;
import net.cassite.pure.ioc.handlers.ParamAnnotationHandler;
import net.cassite.pure.ioc.handlers.ParamHandlerChain;
import static net.cassite.style.Style.*;
import static net.cassite.style.aggregation.Aggregation.*;
import net.cassite.style.reflect.MemberSup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Handler for Force annotation.
* forces a value to be what the string represents.
*
* @author wkgcass
* @see Force
*/
public class ParamForceHandler implements ParamAnnotationHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ParamForceHandler.class);
@Override
public boolean canHandle(Annotation[] annotations) {
for (Annotation ann : annotations) {
if (ann.annotationType() == Force.class) {
return true;
}
}
return false;
}
@Override
public Object handle(Scope scope, MemberSup> caller, Class> cls, Class> expectedClass, Annotation[] toHandle, ParamHandlerChain chain) throws AnnotationHandlingException {
LOGGER.debug("Entered ParamForceHandler with args:\n\tcaller:\t{}\n\tcls:\t{}\n\ttoHandle:\t{}\n\tchain:\t{}",
caller, cls, toHandle, chain);
try {
return chain.next().handle(scope, caller, cls, expectedClass, toHandle, chain);
} catch (IrrelevantAnnotationHandlingException e) {
LOGGER.debug("Start handling with ParamForceHandler");
return If((Force) $(toHandle).findOne(a -> a.annotationType() == Force.class), f -> {
String value = f.value();
if (!f.properties().equals("")) {
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy