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

tfw.swing.SwingUtil Maven / Gradle / Ivy

Go to download

The FrameWork for building highly scalable and maintainable applications

The newest version!
package tfw.swing;

import tfw.check.Argument;
import tfw.tsm.Branch;
import tfw.tsm.BranchBox;
import tfw.tsm.TreeComponent;

public final class SwingUtil {
    private SwingUtil() {}

    public static void addObjectToBranch(final Object object, final Branch branch) {
        Argument.assertNotNull(object, "object");
        Argument.assertNotNull(branch, "branch");

        if (object instanceof BranchBox) {
            branch.add((BranchBox) object);
        } else if (object instanceof TreeComponent) {
            branch.add((TreeComponent) object);
        } else {
            throw new IllegalArgumentException("object != (BranchBox || TreeComponent) not allowed!");
        }
    }

    public static void removeObjectFromBranch(final Object object, final Branch branch) {
        Argument.assertNotNull(object, "object");
        Argument.assertNotNull(branch, "branch");

        if (object instanceof BranchBox) {
            branch.remove((BranchBox) object);
        } else if (object instanceof TreeComponent) {
            branch.remove((TreeComponent) object);
        } else {
            throw new IllegalArgumentException("object != (BranchBox || TreeComponent) not allowed!");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy