亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? classmapbuilder.java

?? 一個javabean的轉換與copy非常的好用希望大家好好研究一下
?? JAVA
字號:
/*
 * Copyright 2005-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.sf.dozer.util.mapping.util;

import java.beans.PropertyDescriptor;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;

import net.sf.dozer.util.mapping.fieldmap.ClassMap;
import net.sf.dozer.util.mapping.fieldmap.Configuration;
import net.sf.dozer.util.mapping.fieldmap.DozerClass;
import net.sf.dozer.util.mapping.fieldmap.ExcludeFieldMap;
import net.sf.dozer.util.mapping.fieldmap.Field;
import net.sf.dozer.util.mapping.fieldmap.FieldMap;
import net.sf.dozer.util.mapping.fieldmap.GenericFieldMap;
import net.sf.dozer.util.mapping.fieldmap.MapFieldMap;


/**
 * @author tierney.matt
 * @author garsombke.franz
 */
public class ClassMapBuilder {
  private final ReflectionUtils reflectionUtils = new ReflectionUtils();
  private final MappingUtils mappingUtils = new MappingUtils();
  
  public ClassMap createDefaultClassMap(Configuration globalConfiguration, Class sourceClass, Class destClass) {
    ClassMap classMap = new ClassMap();
    classMap.setSourceClass(new DozerClass(sourceClass.getName(), sourceClass, null, null, null, null, 
        Boolean.valueOf(MapperConstants.DEFAULT_MAP_NULL_POLICY), Boolean.valueOf(MapperConstants.DEFAULT_MAP_EMPTY_STRING_POLICY)));
    classMap.setDestClass(new DozerClass(destClass.getName(), destClass, null, null, null, null,
        Boolean.valueOf(MapperConstants.DEFAULT_MAP_NULL_POLICY), Boolean.valueOf(MapperConstants.DEFAULT_MAP_EMPTY_STRING_POLICY)));

    if (globalConfiguration == null) {
      // a default class map inherits the global properties
      classMap.setWildcard(classMap.getConfiguration().getWildcard());
      classMap.setStopOnErrors(classMap.getConfiguration().getStopOnErrors());
      classMap.setDateFormat(classMap.getConfiguration().getDateFormat());
    } else {
      classMap.setWildcard(globalConfiguration.getWildcard());
      classMap.setStopOnErrors(globalConfiguration.getStopOnErrors());
      classMap.setDateFormat(globalConfiguration.getDateFormat());
      classMap.setConfiguration(globalConfiguration);
    }
    // Add default field mappings if wildcard policy is true
    if (classMap.isWildcard()) {
      addDefaultFieldMappings(classMap);
    }

    return classMap;
  }
  
  public void addDefaultFieldMappings(Map customMappings) {
    Set entries = customMappings.entrySet();
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      ClassMap classMap = (ClassMap) entry.getValue();

      if (classMap.isWildcard()) {
        addDefaultFieldMappings(classMap);
      }
    }
  }

  public void addMapDefaultFieldMappings(ClassMap classMap) {
    Class sourceClass = classMap.getSourceClass().getClassToMap();
    Class destClass = classMap.getDestClass().getClassToMap();
    PropertyDescriptor[] properties = null;
    boolean destIsMap = false;
    // determine which is the map
    if (mappingUtils.isSupportedMap(sourceClass) || classMap.getSourceClass().getMapGetMethod() != null) {
      properties = PropertyUtils.getPropertyDescriptors(destClass);
      destIsMap = false;
    } else if (mappingUtils.isSupportedMap(destClass) || classMap.getDestClass().getMapGetMethod() != null) {
      properties = PropertyUtils.getPropertyDescriptors(sourceClass);
      destIsMap = true;
    } else {
      return;
    }
    for (int i = 0; i < properties.length; i++) {
      String fieldName = properties[i].getName();
      // if the sourceProperty is null we know that there is not a
      // corresponding property to map to.
      if (fieldName.equals("class")) {
        continue;
      }
      MapFieldMap map = new MapFieldMap();
      if (destIsMap) {
        map.setSourceField(new Field(fieldName, null));
        Field df = new Field(MapperConstants.SELF_KEYWORD, null);
        if (StringUtils.isNotEmpty(classMap.getDestClass().getMapGetMethod())) {
          df.setMapGetMethod(classMap.getDestClass().getMapGetMethod());
          df.setTheGetMethod(classMap.getDestClass().getMapGetMethod());
        } else {
          df.setMapGetMethod("get");
          df.setTheGetMethod("get");
        }
        if (StringUtils.isNotEmpty(classMap.getDestClass().getMapSetMethod())) {
          df.setMapSetMethod(classMap.getDestClass().getMapSetMethod());
          df.setTheSetMethod(classMap.getDestClass().getMapSetMethod());
        } else {
          df.setMapSetMethod("put");
          df.setTheSetMethod("put");
        }
        map.setDestField(df);
        FieldMap fieldMap = classMap.getFieldMapUsingSource(fieldName);
        // this means we have an existing fieldmap. set default values accordingly
        if (fieldMap != null && !(fieldMap instanceof ExcludeFieldMap)) {
          map.getSourceField().setTheGetMethod(fieldMap.getSourceField().getTheGetMethod());
          map.getSourceField().setTheSetMethod(fieldMap.getSourceField().getTheSetMethod());
          df.setKey(fieldMap.getDestField().getKey());
          map.getSourceField().setKey(fieldMap.getDestField().getKey());
          classMap.removeFieldMapping(fieldMap);
        } else if (fieldMap instanceof ExcludeFieldMap) {
          fieldMap.setDestField(df);
          continue;
        }
      } else {
        map.setDestField(new Field(fieldName, null));
        Field sourceField = new Field(MapperConstants.SELF_KEYWORD, null);
        if (StringUtils.isNotEmpty(classMap.getSourceClass().getMapGetMethod())) {
          sourceField.setMapGetMethod(classMap.getSourceClass().getMapGetMethod());
          sourceField.setTheGetMethod(classMap.getSourceClass().getMapGetMethod());
        } else {
          sourceField.setMapGetMethod("get");
          sourceField.setTheGetMethod("get");
        }
        if (StringUtils.isNotEmpty(classMap.getSourceClass().getMapSetMethod())) {
          sourceField.setMapSetMethod(classMap.getSourceClass().getMapSetMethod());
          sourceField.setTheSetMethod(classMap.getSourceClass().getMapSetMethod());
        } else {
          sourceField.setMapSetMethod("put");
          sourceField.setTheSetMethod("put");
        }
        map.setSourceField(sourceField);
        FieldMap fieldMap = classMap.getFieldMapUsingDest(fieldName);
        // this means we have an existing fieldmap. set default values accordingly
        if (fieldMap != null && !(fieldMap instanceof ExcludeFieldMap)) {
          map.getDestField().setTheGetMethod(fieldMap.getDestField().getTheGetMethod());
          map.getDestField().setTheSetMethod(fieldMap.getDestField().getTheSetMethod());
          sourceField.setKey(fieldMap.getSourceField().getKey());
          map.getDestField().setKey(fieldMap.getSourceField().getKey());
          classMap.removeFieldMapping(fieldMap);
        } else if (fieldMap instanceof ExcludeFieldMap) {
          fieldMap.setSourceField(sourceField);
          continue;
        }
      }
      classMap.addFieldMapping(map);
    }
  }

  private void addDefaultFieldMappings(ClassMap classMap) {
    Class sourceClass = classMap.getSourceClass().getClassToMap();
    Class destClass = classMap.getDestClass().getClassToMap();
    PropertyDescriptor[] destProperties = PropertyUtils.getPropertyDescriptors(destClass);
    for (int i = 0; i < destProperties.length; i++) {
      String destFieldName = destProperties[i].getName();
      PropertyDescriptor sourceProperty = reflectionUtils.getPropertyDescriptor(sourceClass, destFieldName);
      // if the sourceProperty is null we know that there is not a
      // corresponding property to map to.
      if (destFieldName.equals("class") || sourceProperty == null) {
        continue;
      }

      if (classMap.getFieldMapUsingDest(destFieldName) != null) {
        continue;
      }
      GenericFieldMap map = new GenericFieldMap();
      map.setSourceField(new Field(destFieldName, null));
      map.setDestField(new Field(destFieldName, null));
      classMap.addFieldMapping(map);
    }
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线一区二区观看| 欧美一级片在线观看| 午夜精品成人在线| 中文字幕av在线一区二区三区| 欧美日韩一二三| www.一区二区| 国产一区二区三区香蕉 | 日韩一区二区电影在线| 成人手机在线视频| 蜜臀久久99精品久久久久宅男 | 成人h版在线观看| 九色综合狠狠综合久久| 亚洲伊人伊色伊影伊综合网| 中文字幕av一区二区三区高| 久久综合狠狠综合久久激情| 欧美日韩高清一区二区不卡| 成人看片黄a免费看在线| 久久99国产精品久久| 午夜精品aaa| 亚洲国产日日夜夜| 亚洲制服丝袜av| 自拍偷拍欧美精品| 秋霞电影网一区二区| 亚洲国产毛片aaaaa无费看| 国产精品美女视频| 国产欧美日韩激情| 国产三级精品视频| 欧美激情一区在线观看| 久久日韩精品一区二区五区| 日韩你懂的在线观看| 日韩一级精品视频在线观看| 欧美二区三区91| 欧美精品v国产精品v日韩精品| 在线欧美一区二区| 在线欧美小视频| 色狠狠一区二区| 91美女在线视频| 一本色道a无线码一区v| 一本一道久久a久久精品综合蜜臀| 风间由美性色一区二区三区| 国产成人午夜精品5599 | 成人综合激情网| 国产69精品久久99不卡| 国产91综合一区在线观看| 大桥未久av一区二区三区中文| 国产白丝精品91爽爽久久| 成人妖精视频yjsp地址| 91农村精品一区二区在线| 91年精品国产| 欧美羞羞免费网站| 欧美精品一二三区| 日韩精品一区二区三区视频播放| 欧美变态tickling挠脚心| 久久精品人人做人人综合| 国产精品欧美经典| 亚洲蜜臀av乱码久久精品蜜桃| 一区二区三区不卡在线观看| 天堂成人免费av电影一区| 男女男精品网站| 国产精品性做久久久久久| 99视频在线精品| 91蜜桃婷婷狠狠久久综合9色| 欧美日韩中字一区| 精品日韩99亚洲| 亚洲欧洲一区二区在线播放| 亚洲一卡二卡三卡四卡无卡久久| 午夜欧美视频在线观看| 国内精品伊人久久久久影院对白| 国产99一区视频免费| 在线免费观看日本欧美| 日韩欧美视频一区| 国产精品嫩草影院com| 一区二区三区av电影| 美女视频黄 久久| 成人午夜视频免费看| 欧美三级电影在线观看| 337p日本欧洲亚洲大胆精品| 国产精品乱子久久久久| 午夜一区二区三区在线观看| 激情综合五月婷婷| 91丨九色丨国产丨porny| 欧美一区国产二区| 国产精品福利一区| 青青草原综合久久大伊人精品| 69精品人人人人| 欧美经典三级视频一区二区三区| 亚洲午夜一二三区视频| 国内精品视频666| 在线一区二区三区| 国产视频在线观看一区二区三区| 洋洋av久久久久久久一区| 国内精品国产成人国产三级粉色| 99国产精品久久久久久久久久 | 久久综合狠狠综合| 亚洲国产欧美另类丝袜| 丰满亚洲少妇av| 日韩欧美一区二区免费| 一区二区三区欧美视频| 国产成人午夜精品影院观看视频| 欧美福利一区二区| 中文字幕日本乱码精品影院| 麻豆91精品视频| 欧美在线一二三| 国产精品日韩成人| 国产一区二区三区四| 欧美日韩精品欧美日韩精品一| 欧美国产精品一区| 精品一区二区三区在线观看国产| 91福利在线看| 国产精品福利一区二区三区| 国产麻豆欧美日韩一区| 日韩你懂的电影在线观看| 亚洲成人av一区二区三区| 91网站黄www| 国产精品二区一区二区aⅴ污介绍| 国产乱对白刺激视频不卡| 欧美一区二区视频在线观看 | 国产风韵犹存在线视精品| 日韩一区二区三区视频在线| 亚洲成人自拍偷拍| 欧美性三三影院| 国产精品久久久久久久久晋中| 狠狠色丁香久久婷婷综合_中| 3751色影院一区二区三区| 亚洲一二三区不卡| 在线日韩av片| 夜夜操天天操亚洲| 91福利在线观看| 亚洲综合色婷婷| 欧美无人高清视频在线观看| 亚洲综合色自拍一区| 91女厕偷拍女厕偷拍高清| 亚洲桃色在线一区| 91碰在线视频| 一区二区欧美在线观看| 欧美亚洲国产一区二区三区va| 亚洲免费电影在线| 欧美视频在线一区| 亚洲国产精品影院| 欧美在线播放高清精品| 午夜精品福利一区二区三区av| 欧美日韩国产美女| 日韩精品一卡二卡三卡四卡无卡| 欧美精品一二三四| 麻豆成人91精品二区三区| 精品国产第一区二区三区观看体验| 蜜桃一区二区三区在线| 26uuu亚洲| 大陆成人av片| 亚洲激情六月丁香| 欧美日韩欧美一区二区| 日本特黄久久久高潮| 欧美变态tickle挠乳网站| 国产成人综合在线播放| 国产精品国产三级国产普通话99| 91社区在线播放| 天堂精品中文字幕在线| 亚洲精品一区二区三区精华液| 国产福利一区在线观看| 亚洲天堂a在线| 欧美日韩午夜在线视频| 精品无码三级在线观看视频| 欧美激情一区二区三区蜜桃视频| 91色视频在线| 蜜桃av一区二区三区电影| 国产女同互慰高潮91漫画| 91女神在线视频| 男人的天堂久久精品| 亚洲国产电影在线观看| 欧美中文字幕久久| 精品一区二区三区在线观看| 最新国产精品久久精品| 日韩一区和二区| www.久久久久久久久| 首页亚洲欧美制服丝腿| 久久九九久久九九| 欧美自拍偷拍一区| 韩国视频一区二区| 一卡二卡三卡日韩欧美| 精品久久久影院| 在线免费不卡电影| 国产成人综合亚洲网站| 午夜精品久久久久久久| 国产精品三级av在线播放| 在线播放视频一区| voyeur盗摄精品| 麻豆91小视频| 夜夜揉揉日日人人青青一国产精品 | 中文字幕在线观看一区二区| 91麻豆精品国产91久久久久久久久| 国产精品1区2区3区| 亚洲成人资源网| 中日韩av电影| 日韩一区二区精品葵司在线| 色综合中文字幕国产 | 99精品视频中文字幕| 男男视频亚洲欧美| 一区二区三区四区亚洲| 欧美激情一二三区| 日韩欧美国产系列|