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

net.sourceforge.marathon.javafxagent.components.ContextManager Maven / Gradle / Ivy

There is a newer version: 5.4.0.0
Show newest version
/*******************************************************************************
 * Copyright 2016 Jalian Systems Pvt. Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package net.sourceforge.marathon.javafxagent.components;

import java.util.LinkedList;
import java.util.logging.Logger;

import javafx.scene.Node;

public class ContextManager {

    public static final Logger LOGGER = Logger.getLogger(ContextManager.class.getName());

    private static class InstanceCheck implements IContextChecker {

        private Class componentClass;

        public InstanceCheck(Class klass) {
            componentClass = klass;
        }

        @Override
        public boolean isContext(Node c) {
            return componentClass.isInstance(c);
        }

    }

    private static LinkedList containers = new LinkedList();

    static {
    }

    public static void add(Class klass) {
        add(new InstanceCheck(klass));
    }

    public static void add(IContextChecker e) {
        containers.addFirst(e);
    }

    public static boolean isContext(Node c) {
        for (IContextChecker checker : containers) {
            if (checker.isContext(c)) {
                return true;
            }
        }
        return false;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy