org.nutz.dao.util.RelationObjectMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nutz Show documentation
Show all versions of nutz Show documentation
Nutz, which is a collections of lightweight frameworks, each of them can be used independently
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);
}
}