// Path: QuickProject-Core/src/main/java/chanedi/model/Entity.java
// @Data
// public abstract class Entity implements Serializable {
// 
//     private static final long serialVersionUID = 4212679023438415647L;
// 
//     public abstract Object getId();
// 
//     public abstract void setId(Object id);
// 
// }
// 
// Path: QuickProject-Util/src/main/java/chanedi/util/ReflectUtils.java
// public class ReflectUtils {
// 
//     public static PropertyDescriptor[] getBeanSetters(Class<?> type) {
//         return org.springframework.cglib.core.ReflectUtils.getBeanSetters(type);
//     }
// 
//     public static PropertyDescriptor[] getBeanGetters(Class<?> type) {
//         return org.springframework.cglib.core.ReflectUtils.getBeanGetters(type);
//     }
// 
//     public static Method getBeanGetter(Class<?> beanClass, String propertyName) throws IntrospectionException {
//         return new PropertyDescriptor(propertyName, beanClass).getReadMethod();
//     }
// 
//     public static Method getBeanSetter(Class<?> beanClass, String propertyName) throws IntrospectionException {
//         return new PropertyDescriptor(propertyName, beanClass).getWriteMethod();
//     }
// 
//     public static Field getFieldByGetter(Class<?> modelClass, String getterName) throws NoSuchFieldException {
//         String propName = org.apache.commons.lang3.StringUtils.uncapitalize(getterName.substring(3));
//         return modelClass.getDeclaredField(propName);
//     }
// 
//     public static Field getFieldBySetter(Class<?> modelClass, String setterName) throws NoSuchFieldException {
//         String propName = org.apache.commons.lang3.StringUtils.uncapitalize(setterName.substring(3));
//         return modelClass.getDeclaredField(propName);
//     }
// 
// }


import chanedi.model.Entity;
import chanedi.util.ReflectUtils;
import lombok.extern.slf4j.Slf4j;
import java.beans.PropertyDescriptor;
import java.util.HashMap;
import java.util.Map;
package chanedi.dao.impl.mybatis.modelParser;



/**
 * @author Chanedi
 */
@Slf4j
public class ModelUtils {

    public static Map<String, Property> getProperties(Entity entity, ColumnTarget columnTarget) {
        Class<?> modelClass = entity.getClass();
        Map<String, Property> properties = getProperties(modelClass, columnTarget);
        Map<String, Property> results = new HashMap<String, Property>(properties.size());
        for (Map.Entry<String, Property> propertyEntry : properties.entrySet()) {
            Property property = propertyEntry.getValue();
            if (columnTarget == ColumnTarget.INSERT || columnTarget == ColumnTarget.UPDATE || columnTarget == ColumnTarget.WHERE) {
                boolean isIgnore;
                try {
                    isIgnore = property.isNullValue(entity);
                } catch (Exception e) {
                    isIgnore = true;
                }
                if (isIgnore) { // 空值忽略
                    continue;
                }
            }

            results.put(propertyEntry.getKey(), property);
        }

        return results;
    }

    /**
     * @param columnTarget 允许为null
     */
    public static Map<String, Property> getProperties(Class<?> modelClass, ColumnTarget columnTarget) {
// Path: QuickProject-Core/src/main/java/chanedi/model/Entity.java
// @Data
// public abstract class Entity implements Serializable {
// 
//     private static final long serialVersionUID = 4212679023438415647L;
// 
//     public abstract Object getId();
// 
//     public abstract void setId(Object id);
// 
// }
// 
// Path: QuickProject-Util/src/main/java/chanedi/util/ReflectUtils.java
// public class ReflectUtils {
// 
//     public static PropertyDescriptor[] getBeanSetters(Class<?> type) {
//         return org.springframework.cglib.core.ReflectUtils.getBeanSetters(type);
//     }
// 
//     public static PropertyDescriptor[] getBeanGetters(Class<?> type) {
//         return org.springframework.cglib.core.ReflectUtils.getBeanGetters(type);
//     }
// 
//     public static Method getBeanGetter(Class<?> beanClass, String propertyName) throws IntrospectionException {
//         return new PropertyDescriptor(propertyName, beanClass).getReadMethod();
//     }
// 
//     public static Method getBeanSetter(Class<?> beanClass, String propertyName) throws IntrospectionException {
//         return new PropertyDescriptor(propertyName, beanClass).getWriteMethod();
//     }
// 
//     public static Field getFieldByGetter(Class<?> modelClass, String getterName) throws NoSuchFieldException {
//         String propName = org.apache.commons.lang3.StringUtils.uncapitalize(getterName.substring(3));
//         return modelClass.getDeclaredField(propName);
//     }
// 
//     public static Field getFieldBySetter(Class<?> modelClass, String setterName) throws NoSuchFieldException {
//         String propName = org.apache.commons.lang3.StringUtils.uncapitalize(setterName.substring(3));
//         return modelClass.getDeclaredField(propName);
//     }
// 
// }


// Path: QuickProject-Core/src/main/java/chanedi/dao/impl/mybatis/modelParser/ModelUtils.java
import chanedi.model.Entity;
import chanedi.util.ReflectUtils;
import lombok.extern.slf4j.Slf4j;
import java.beans.PropertyDescriptor;
import java.util.HashMap;
import java.util.Map;

package chanedi.dao.impl.mybatis.modelParser;



/**
 * @author Chanedi
 */
@Slf4j
public class ModelUtils {

    public static Map<String, Property> getProperties(Entity entity, ColumnTarget columnTarget) {
        Class<?> modelClass = entity.getClass();
        Map<String, Property> properties = getProperties(modelClass, columnTarget);
        Map<String, Property> results = new HashMap<String, Property>(properties.size());
        for (Map.Entry<String, Property> propertyEntry : properties.entrySet()) {
            Property property = propertyEntry.getValue();
            if (columnTarget == ColumnTarget.INSERT || columnTarget == ColumnTarget.UPDATE || columnTarget == ColumnTarget.WHERE) {
                boolean isIgnore;
                try {
                    isIgnore = property.isNullValue(entity);
                } catch (Exception e) {
                    isIgnore = true;
                }
                if (isIgnore) { // 空值忽略
                    continue;
                }
            }

            results.put(propertyEntry.getKey(), property);
        }

        return results;
    }

    /**
     * @param columnTarget 允许为null
     */
    public static Map<String, Property> getProperties(Class<?> modelClass, ColumnTarget columnTarget) {
        PropertyDescriptor[] propDescriptors = ReflectUtils.getBeanGetters(modelClass);