// Path: src/main/java/ru/vyarus/guice/ext/core/util/Utils.java
// public final class Utils {
// 
//     private Utils() {
//     }
// 
//     /**
//      * Important check, because JDK proxies of public interfaces have no package
//      * (thanks to @binkley https://github.com/99soft/lifegycle/pull/5).
//      *
//      * @param type class type to check
//      * @return true if package could be resolved, false otherwise
//      */
//     public static boolean isPackageValid(final Class type) {
//         boolean res = false;
//         if (type != null) {
//             final Package packaj = type.getPackage();
//             res = !(packaj == null || packaj.getName().startsWith("java"));
//         }
//         return res;
//     }
// 
//     /**
//      * Checks that method has no parameters, otherwise throws exception.
//      *
//      * @param method method to check
//      */
//     public static void checkNoParams(final Method method) {
//         if (method.getParameterTypes().length > 0) {
//             throw new IllegalStateException("Method without parameters required");
//         }
//     }
// 
//     /**
//      * Note: versions below 1.8 are not supported.
//      *
//      * @return true if current java is 1.8, otherwise assumed 9 or above
//      */
//     public static boolean isJava8() {
//         final String version = System.getProperty("java.version");
//         return version.startsWith("1.8");
//     }
// }


import com.google.inject.TypeLiteral;
import com.google.inject.spi.InjectionListener;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
import ru.vyarus.guice.ext.core.util.Utils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
package ru.vyarus.guice.ext.core.method;



/**
 * Generic type listener to process annotated methods after bean instantiation.
 *
 * @author Vyacheslav Rusakov
 * @since 30.06.2014
 * @param <T> annotation type
 */
public class AnnotatedMethodTypeListener<T extends Annotation> implements TypeListener {

    private final Class<T> annotationClass;
    private final MethodPostProcessor<T> postProcessor;


    public AnnotatedMethodTypeListener(final Class<T> annotationClass,
                                       final MethodPostProcessor<T> postProcessor) {
        this.annotationClass = annotationClass;
        this.postProcessor = postProcessor;
    }

    @Override
    @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    public <I> void hear(final TypeLiteral<I> type, final TypeEncounter<I> encounter) {
        final Class<? super I> actualType = type.getRawType();
// Path: src/main/java/ru/vyarus/guice/ext/core/util/Utils.java
// public final class Utils {
// 
//     private Utils() {
//     }
// 
//     /**
//      * Important check, because JDK proxies of public interfaces have no package
//      * (thanks to @binkley https://github.com/99soft/lifegycle/pull/5).
//      *
//      * @param type class type to check
//      * @return true if package could be resolved, false otherwise
//      */
//     public static boolean isPackageValid(final Class type) {
//         boolean res = false;
//         if (type != null) {
//             final Package packaj = type.getPackage();
//             res = !(packaj == null || packaj.getName().startsWith("java"));
//         }
//         return res;
//     }
// 
//     /**
//      * Checks that method has no parameters, otherwise throws exception.
//      *
//      * @param method method to check
//      */
//     public static void checkNoParams(final Method method) {
//         if (method.getParameterTypes().length > 0) {
//             throw new IllegalStateException("Method without parameters required");
//         }
//     }
// 
//     /**
//      * Note: versions below 1.8 are not supported.
//      *
//      * @return true if current java is 1.8, otherwise assumed 9 or above
//      */
//     public static boolean isJava8() {
//         final String version = System.getProperty("java.version");
//         return version.startsWith("1.8");
//     }
// }


// Path: src/main/java/ru/vyarus/guice/ext/core/method/AnnotatedMethodTypeListener.java
import com.google.inject.TypeLiteral;
import com.google.inject.spi.InjectionListener;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
import ru.vyarus.guice.ext.core.util.Utils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

package ru.vyarus.guice.ext.core.method;



/**
 * Generic type listener to process annotated methods after bean instantiation.
 *
 * @author Vyacheslav Rusakov
 * @since 30.06.2014
 * @param <T> annotation type
 */
public class AnnotatedMethodTypeListener<T extends Annotation> implements TypeListener {

    private final Class<T> annotationClass;
    private final MethodPostProcessor<T> postProcessor;


    public AnnotatedMethodTypeListener(final Class<T> annotationClass,
                                       final MethodPostProcessor<T> postProcessor) {
        this.annotationClass = annotationClass;
        this.postProcessor = postProcessor;
    }

    @Override
    @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    public <I> void hear(final TypeLiteral<I> type, final TypeEncounter<I> encounter) {
        final Class<? super I> actualType = type.getRawType();
        if (!Utils.isPackageValid(actualType)) {