package net.ranides.assira.reflection;

import net.ranides.assira.generic.Ref;
import net.ranides.assira.reflection.BeanModel.FluentMap;

import java.util.Map;

public class BeanModelUtils {

    public static Ref<BeanMethodBinding> method(Object that, String name) {
        return BeanModel.typefor(that).method(name).map(v -> v.bind(that));
    }

    public static Map<String, Object> properties(Object that) {
        return BeanModel.typefor(that).properties(that);
    }

    public static Ref<BeanPropertyBinding<Object>> property(Object that, String property) {
        return BeanModel.typefor(that).property(property).map(v -> v.bind(that));
    }

    public static void set(Object that, String property, Object value) {
        BeanModel.typefor(that).property(property).get().set(that, value);
    }

    public static Object get(Object that, String property) {
        return BeanModel.typefor(that).property(property).get().get(that);
    }

    public static FluentMap fluent(Object that) {
        return BeanModel.typefor(that).fluent(that);
    }

    public static Object clone(Object that) {
        return BeanModel.typefor(that).clone(that);
    }

}
