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

commons.box.app.MetaBeanConfig Maven / Gradle / Ivy

The newest version!
package commons.box.app;

import commons.box.app.bean.MetaAccess;
import commons.box.app.bean.MetaAccessProperty;
import commons.box.util.Collects;
import commons.box.util.MBs;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.*;

/**
 *
 */
public interface MetaBeanConfig extends MetaAccess, MetaLabel, HasKey, DataName, DataLabel, DataObject, Cloneable {
    /** 默认实现 name=key */
    @Nonnull
    @Override
    default String name() {
        return this.key();
    }

    /**
     * 创建新实例,对象内部属性值根据 props 生成且属性值为均空(默认值)
     *
     * @return
     */
    @Nonnull
    public MetaBean inst(@Nullable Map map);

    /**
     * 获取实例
     *
     * @param maps
     * @return
     */
    @Nonnull
    default MetaBean[] insts(@Nullable Map[] maps) {
        if (Collects.isEmpty(maps)) return MBs.EMPTY;
        MetaBean[] mbs = new MetaBean[maps.length];
        for (int i = 0; i < maps.length; i++) mbs[i] = this.inst(maps[i]);
        return mbs;
    }

    /**
     * 获取实例
     *
     * @param maps
     * @return
     */
    @Nonnull
    default List insts(@Nullable Collection> maps) {
        if (Collects.isEmpty(maps)) return Collects.immlist();
        List mbs = new ArrayList<>(maps.size());
        for (Map m : maps) mbs.add(this.inst(m));
        return mbs;
    }

    /**
     * 获取属性
     *
     * @return
     */
    public Map> props();

    /**
     * 获取属性 为了避免与上级接口冲突 获取属性列表可通过此方法直接返回类型兼容的实例
     *
     * @return
     */
    public Map> propsMB();

    /**
     * 获取属性名称
     *
     * @return
     */
    public Set propNames();

    /**
     * 属性访问器
     *
     * @param name
     * @param 

* @return */ public

MetaBeanConfigProperty

prop(String name); /** * 额外的配置项目 * * @return */ public Map extprops(); /** * 额外的配置项目 * * @param key * @return */ public Serializable extprop(String key); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy