package net.ranides.assira.ui.query;

import javax.accessibility.AccessibleContext;
import net.ranides.assira.generic.Ref;
import net.ranides.assira.reflection.BeanPropertyBinding;
import net.ranides.assira.reflection.IClass;

import java.awt.*;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;

public interface IComponent {

    static IComponent of(Component component) {
        return new RComponent(component);
    }

    IClass<?> type();

    IComponent root();

    IComponent parent();

    String name();

    AccessibleContext accessible();

    Map<String, Object> properties();

    BeanPropertyBinding<Object> property(String name);

    void property(String name, Object value);

    void set(String name, Object value);

    Object get(String name);

    IComponents children();

    Ref<IComponent> child(int index);

    Ref<IComponent> child(String name);

    IComponents find(String path);

    IComponents find(String[] path);

    IComponents find(Predicate<IComponent> visitor);

    boolean isContainer();

    boolean isType(Class<?> type);

    Component unwrap();

    <T extends Component> T unwrap(Class<T> type);

    void add(Component component);

    void add(IComponent component);

}
