All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mictaege.jitter.plugin.OnlyIfMethodProcessor Maven / Gradle / Ivy

package com.github.mictaege.jitter.plugin;

import com.github.mictaege.jitter.api.OnlyIf;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.declaration.CtMethod;

import java.util.List;

import static com.github.mictaege.jitter.plugin.JitterUtil.log;
import static java.util.Arrays.asList;

public class OnlyIfMethodProcessor extends AbstractAnnotationProcessor> {

    @Override
    public void process(final OnlyIf annotation, final CtMethod method) {
        final List flavours = asList(annotation.value());
        if (flavours.stream().noneMatch(JitterUtil::active)) {
            log().info("Remove method " + method.getDeclaringType().getSimpleName() + "#" + method.getSimpleName());
            method.delete();
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy