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

tech.guyi.ipojo.compile.lib.classes.ClassCompiler Maven / Gradle / Ivy

There is a newer version: 1.0.0.4
Show newest version
package tech.guyi.ipojo.compile.lib.classes;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.NotFoundException;
import tech.guyi.ipojo.compile.lib.compile.entry.CompileClass;
import tech.guyi.ipojo.compile.lib.configuration.Compile;

import java.io.IOException;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

public class ClassCompiler {

    private ClassScanner scanner = new ClassScanner();
    private ClassEditor editor = new ClassEditor();

    public Set compile(ClassPool pool, Compile compile) throws IOException, NotFoundException {
        return this.scanner.getComponent(pool,compile)
                .stream()
                .map(component -> {
                    try {
                        editor.addInjectMethod(pool,component.getClasses(),compile);
                        return component;
                    } catch (CannotCompileException | NotFoundException e) {
                        e.printStackTrace();
                        return null;
                    }
                })
                .filter(Objects::nonNull)
                .collect(Collectors.toSet());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy