Package org.nutz.dao.impl.sql.pojo

Source Code of org.nutz.dao.impl.sql.pojo.AbstractPItem

package org.nutz.dao.impl.sql.pojo;

import org.nutz.dao.FieldMatcher;
import org.nutz.dao.entity.Entity;
import org.nutz.dao.entity.MappingField;
import org.nutz.dao.sql.Pojo;
import org.nutz.dao.sql.PItem;
import org.nutz.dao.sql.SqlType;

public abstract class AbstractPItem implements PItem {

    protected Pojo pojo;

    public Pojo getPojo() {
        return pojo;
    }

    public void setPojo(Pojo pojo) {
        this.pojo = pojo;
        this.setupPojo(pojo);
    }

    protected SqlType getSqlType() {
        return pojo.getSqlType();
    }

    protected FieldMatcher getFieldMatcher() {
        return pojo.getContext().getFieldMatcher();
    }

    protected void setupPojo(Pojo pojo) {}

    protected Entity<?> _en(Entity<?> en) {
        if (null == en && null != pojo)
            return pojo.getEntity();
        return en;
    }

    protected String _fmtcolnm(Entity<?> en, String name) {
        if (null == en && null != pojo)
            en = pojo.getEntity();

        if (null != en) {
            MappingField mf = en.getField(name);
            if (null != mf)
                return mf.getColumnName();
        }
        return name;
    }

}
TOP

Related Classes of org.nutz.dao.impl.sql.pojo.AbstractPItem

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.