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

org.nutz.dao.util.RelationObjectMap Maven / Gradle / Ivy

Go to download

Nutz, which is a collections of lightweight frameworks, each of them can be used independently

There is a newer version: 1.r.72
Show newest version
package org.nutz.dao.util;

import org.nutz.dao.impl.entity.field.ManyManyLinkField;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;

/**
 * 为多对多关联做的延迟取值Map
 * 
 * @author zozoh([email protected])
 */
@SuppressWarnings("serial")
public class RelationObjectMap extends NutMap {

    private ManyManyLinkField mm;// TODO 这个字段无法序列化

    private Object host;

    private Object linked;

    public RelationObjectMap() {
        throw Lang.noImplement();
    }

    public RelationObjectMap(ManyManyLinkField mm, Object host, Object linked) {
        this.mm = mm;
        this.host = host;
        this.linked = linked;
        this.put(mm.getFromColumnName(), mm.getHostField().getValue(host));
        this.put(mm.getToColumnName(), mm.getLinkedField().getValue(linked));
    }

    @Override
    public Object get(Object key) {
        if (mm.getFromColumnName().equals(key))
            return mm.getHostField().getValue(host);
        if (mm.getToColumnName().equals(key))
            return mm.getLinkedField().getValue(linked);
        return super.get(key);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy