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

org.aion.avm.core.ClassRenamerBuilder Maven / Gradle / Ivy

There is a newer version: 0.9.6
Show newest version
package org.aion.avm.core;

import java.util.HashSet;
import java.util.Set;
import org.aion.avm.NameStyle;
import org.aion.avm.core.ClassRenamer.ClassCategory;
import org.aion.avm.core.ClassRenamer.NameCategory;

public final class ClassRenamerBuilder {
    private final boolean preserveDebuggability;
    private final NameStyle style;
    private Set jclExceptions = new HashSet<>();
    private NameCategory jclExceptionsCategory = NameCategory.PRE_RENAME;
    private Set userDefinedClasses = new HashSet<>();
    private NameCategory userDefinedClassesCategory = NameCategory.PRE_RENAME;
    private Set prohibitedClasses = new HashSet<>();

    public ClassRenamerBuilder(NameStyle style, boolean preserveDebuggability) {
        this.style = style;
        this.preserveDebuggability = preserveDebuggability;
    }

    public ClassRenamerBuilder loadPreRenameJclExceptionClasses(Set jclExceptions) {
        this.jclExceptions = jclExceptions;
        this.jclExceptionsCategory = NameCategory.PRE_RENAME;
        return this;
    }

    public ClassRenamerBuilder loadPostRenameJclExceptionClasses(Set jclExceptions) {
        this.jclExceptions = jclExceptions;
        this.jclExceptionsCategory = NameCategory.POST_RENAME;
        return this;
    }

    public ClassRenamerBuilder loadPreRenameUserDefinedClasses(Set userDefinedClasses) {
        this.userDefinedClasses = userDefinedClasses;
        this.userDefinedClassesCategory = NameCategory.PRE_RENAME;
        return this;
    }

    public ClassRenamerBuilder loadPostRenameUserDefinedClasses(Set userDefinedClasses) {
        this.userDefinedClasses = userDefinedClasses;
        this.userDefinedClassesCategory = NameCategory.POST_RENAME;
        return this;
    }

    public ClassRenamerBuilder prohibitJclClasses() {
        this.prohibitedClasses.add(ClassCategory.JCL);
        return this;
    }

    public ClassRenamerBuilder prohibitApiClasses() {
        this.prohibitedClasses.add(ClassCategory.API);
        return this;
    }

    public ClassRenamerBuilder prohibitExceptionWrappers() {
        this.prohibitedClasses.add(ClassCategory.EXCEPTION_WRAPPER);
        return this;
    }

    public ClassRenamerBuilder prohibitPreciseArrayTypes() {
        this.prohibitedClasses.add(ClassCategory.PRECISE_ARRAY);
        return this;
    }

    public ClassRenamerBuilder prohibitUnifyingArrayTypes() {
        this.prohibitedClasses.add(ClassCategory.UNIFYING_ARRAY);
        return this;
    }

    public ClassRenamerBuilder prohibitUserClasses() {
        this.prohibitedClasses.add(ClassCategory.USER);
        return this;
    }

    public ClassRenamer build() {
        return new ClassRenamer(
            this.preserveDebuggability,
            this.style,
            this.jclExceptions,
            this.jclExceptionsCategory,
            this.userDefinedClasses,
            this.userDefinedClassesCategory,
            this.prohibitedClasses);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy