エンティティプロパティ記述にエンティティプロパティ情報をマージします。

@param dest エンティティプロパティ記述
@param src エンティティプロパティ情報
@since 1.7.0
963633
protected void mergeEntityProperty(EntityPropertyDesc dest, EntityPropertyInfo src) {
    dest.setEntityClassName(src.entityClass.getName());
    dest.setPropertyClassName(src.propertyField.getType().getName());
    Class<?> maybeNumberClass =
        ClassUtil.toBoxedPrimitiveTypeIfPossible(src.propertyField.getType());
    if (Number.class.isAssignableFrom(maybeNumberClass)) {
      dest.setNumber(true);
    }
    if (src.version != null) {
      dest.setVersion(true);
    }
    if (src.id != null) {
      dest.setId(true);
      if (src.generatedValue != null) {
        switch (src.generatedValue.strategy()) {
          case IDENTITY:
            dest.setGenerationType(GenerationType.IDENTITY);
            break;
          case SEQUENCE:
            dest.setGenerationType(GenerationType.SEQUENCE);
            if (src.sequenceGenerator != null) {
              dest.setInitialValue(src.sequenceGenerator.initialValue());
              dest.setAllocationSize(src.sequenceGenerator.allocationSize());
              dest.setAllocationSize(src.sequenceGenerator.allocationSize());
            }
            break;
          case TABLE:
            dest.setGenerationType(GenerationType.TABLE);
            if (src.tableGenerator != null) {
              dest.setInitialValue(src.tableGenerator.initialValue());
              dest.setAllocationSize(src.tableGenerator.allocationSize());
              dest.setAllocationSize(src.tableGenerator.allocationSize());
            }
            break;
          default:
            break;
        }
      }
    }
  }
981741
public static <T> T copy(Object src, T dest, boolean setDefaultValForNull) throws BeanConverterException {
        if (src == null)
            return null;

        try {
            Class<? extends Object> destClass = dest.getClass();
            Map<String, PropertyDescriptor> srcDescriptors = getCachePropertyDescriptors(src.getClass());
            Map<String, PropertyDescriptor> destDescriptors = getCachePropertyDescriptors(destClass);

            Set<String> keys = destDescriptors.keySet();
            for (String key : keys) {
                PropertyDescriptor srcDescriptor = srcDescriptors.get(key);

                if (srcDescriptor == null)
                    continue;

                PropertyDescriptor destDescriptor = destDescriptors.get(key);

                Object value = srcDescriptor.getReadMethod().invoke(src);

                Class<?> propertyType = destDescriptor.getPropertyType();

                Method writeMethod = destDescriptor.getWriteMethod();
                if (writeMethod == null) {
                    String name = destDescriptor.getName();
                    try {
                        writeMethod = destClass.getMethod("set" + name.substring(0, 1).toUpperCase() + name.substring(1), destDescriptor.getPropertyType());

                        destDescriptor.setWriteMethod(writeMethod);
                    } catch (Exception e) {
                    }
                }
                if (writeMethod != null) {
                    //类型匹配
                    boolean matched = propertyType == srcDescriptor.getPropertyType();
                    if (!matched) {
                    	
                        if (value != null || setDefaultValForNull) {
                        	if(isSimpleDataType(srcDescriptor)){                        		
                        		value = toValue(srcDescriptor, value, propertyType);
                        	}else{
                        		value = copy(value, propertyType);
                        	}
                        }
                    }
                    //设置默认值
                    if (value == null && setDefaultValForNull) {
                        if (destDescriptor.getPropertyType() == Long.class || destDescriptor.getPropertyType() == Integer.class || destDescriptor.getPropertyType() == Short.class || destDescriptor.getPropertyType() == Double.class || destDescriptor.getPropertyType() == Float.class) {
                            value = 0;
                        } else if (destDescriptor.getPropertyType() == String.class) {
                            value = "";
                        } else if (destDescriptor.getPropertyType() == BigDecimal.class) {
                            value = new BigDecimal("0");
                        }
                    }

                    if (value != null) {
                        writeMethod.invoke(dest, value);
                    }
                }
            }

            return dest;
        } catch (Exception e) {
            throw new BeanConverterException(e);
        }
    }
1224163
public static void copyProperties(Object src, Object dst, String... ignoreFields) {
        Class srcClazz = src.getClass();
        Class distClazz = dst.getClass();
        Method[] methods = distClazz.getMethods();
        List<String> ignoreFiledList = Arrays.asList(ignoreFields);
        for (Method dstMethod : methods) { // 遍历目标对象的方法
            if (Modifier.isStatic(dstMethod.getModifiers())
                || !ReflectUtils.isBeanPropertyReadMethod(dstMethod)) {
                // 不是static方法， 是getter方法
                continue;
            }
            String propertyName = ReflectUtils.getPropertyNameFromBeanReadMethod(dstMethod);
            if (ignoreFiledList.contains(propertyName)) {
                // 忽略字段
                continue;
            }
            Class dstReturnType = dstMethod.getReturnType();
            try { // 同时目标字段还需要有set方法
                Method dstSetterMethod = ReflectUtils.getPropertySetterMethod(distClazz, propertyName, dstReturnType);
                if (dstSetterMethod != null) {
                    // 再检查原始对象方法
                    Method srcGetterMethod = ReflectUtils.getPropertyGetterMethod(srcClazz, propertyName);
                    // 原始字段有getter方法
                    Class srcReturnType = srcGetterMethod.getReturnType();
                    if (srcReturnType.equals(dstReturnType)) { // 原始字段和目标字段返回类型一样
                        Object val = srcGetterMethod.invoke(src); // 从原始对象读取值
                        if (val != null) {
                            dstSetterMethod.invoke(dst, val); // 设置到目标对象
                        }
                    }
                }
            } catch (Exception ignore) {
                // ignore 下一循环
            }
        }
    }
623667
protected function copyFileWithDirsCreating($src, $dest)
    {
        $dirPathOfDestFile = dirname($dest);

        if (! File::exists($dirPathOfDestFile)) {
            File::makeDirectory($dirPathOfDestFile, 0755, true);
        }

        if (! File::exists($dest)) {
            File::copy($src, $dest);
        }
    }
980135
public static boolean contains(Object src, Object... dests) {
        if (dests == null) {
            throw new NullPointerException("dest must not be null");
        }

        if (src == null) {
            return false;
        }

        for (Object dest : dests) {
            if (src == dest || src.equals(dest)) {
                return true;
            }
        }
        return false;
    }
1213963
public void parseAndEmit(String srcPath, final String destDir) {    	
    	final String version = new Version().getVersion();
    	logger.info("jADT version " + version + ".");
    	logger.info("Will read from source " + srcPath);
    	logger.info("Will write to destDir " + destDir);
   	
        final List<? extends Source> sources = sourceFactory.createSources(srcPath);
        for (Source source : sources) {
            final List<UserError> errors = new ArrayList<UserError>();
                 
            final ParseResult result = parser.parse(source);
            for (SyntaxError error : result.errors) {
                errors.add(UserError._Syntactic(error));
            }               
            final List<SemanticError> semanticErrors = checker.check(result.doc);
            for (SemanticError error : semanticErrors) {
                errors.add(UserError._Semantic(error));
            }            
            if (!errors.isEmpty()) {
                throw new JADTUserErrorsException(errors);
            }
            emitter.emit(factoryFactory.createSinkFactory(destDir), result.doc);
        }
    }
480776
function (dest, src) {
        var prop;

        // update or add values from src
        for (prop in src) {
            if (src.hasOwnProperty(prop)) {
                dest[prop] = src[prop];
            }
        }

        // remove values that no longer exist
        for (prop in dest) {
            if (dest.hasOwnProperty(prop) && !src.hasOwnProperty(prop)) {
                delete dest[prop];
            }
        }

        return dest;
    }
217409
public static TextContainer copy(TextContainer src, TextContainer dest) {
        return TextParams.copy(src, dest);
    }
1172713
public BufferedImage filter(BufferedImage src, BufferedImage dest) {
        if (dest == null) {
            dest = createCompatibleDestImage(src, null);
        }

        // Make grayscale
        BufferedImage image = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), getRenderingHints()).filter(src, null);

        // Make image faded/too bright
        image = new RescaleOp(1.2f, 120f, getRenderingHints()).filter(image, image);

        // Blur
        image = ImageUtil.blur(image, 2.5f);

        Graphics2D g = dest.createGraphics();
        try {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.drawImage(image, 0, 0, null);

            // Rotate it slightly for a more analogue feeling
            double angle = .0055;
            g.rotate(angle);

            // Apply fake green-ish h-sync line at random position
            Random random = new Random();
            int lineStart = random.nextInt(image.getHeight() - 80);
            int lineHeight = random.nextInt(10) + 20;

            g.setComposite(AlphaComposite.SrcOver.derive(.3f));
            g.setPaint(new LinearGradientPaint(
                    0, lineStart, 0, lineStart + lineHeight,
                    new float[] {0, .3f, .9f, 1},
                    new Color[] {new Color(0, true), new Color(0x90AF66), new Color(0x99606F33, true), new Color(0, true)}
            ));
            g.fillRect(0, lineStart, image.getWidth(), lineHeight);

            // Apply fake large dot-pitch (black lines w/transparency)
            g.setComposite(AlphaComposite.SrcOver.derive(.55f));
            g.setColor(Color.BLACK);

            for (int y = 0; y < image.getHeight(); y += 3) {
                g.setStroke(new BasicStroke(random.nextFloat() / 3 + .8f));
                g.drawLine(0, y, image.getWidth(), y);
            }

            // Vignette/border
            g.setComposite(AlphaComposite.SrcOver.derive(.75f));
            int focus = Math.min(image.getWidth() / 8, image.getHeight() / 8);
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.6f,
                    new Point(focus, focus),
                    new float[] {0, .3f, .9f, 1f},
                    new Color[] {new Color(0x99FFFFFF, true), new Color(0x00FFFFFF, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(-2, -2, image.getWidth() + 4, image.getHeight() + 4);

            g.rotate(-angle);

            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.65f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .85f, 1f},
                    new Color[] {new Color(0x0, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());

            // Highlight
            g.setComposite(AlphaComposite.SrcOver.derive(.55f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth(), image.getHeight()),
                    Math.max(image.getWidth(), image.getHeight()) * 1.1f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .75f, 1f},
                    new Color[] {new Color(0x00FFFFFF, true), new Color(0x00FFFFFF, true), Color.WHITE},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
        }
        finally {
            g.dispose();
        }

        // Round corners
        BufferedImage foo = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = foo.createGraphics();
        try {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            graphics.setColor(Color.WHITE);
            double angle = -0.04;
            g.rotate(angle);
            graphics.fillRoundRect(1, 1, image.getWidth() - 2, image.getHeight() - 2, 20, 20);
        }
        finally {
            graphics.dispose();
        }

        foo = ImageUtil.blur(foo, 4.5f);

        // Compose image into rounded corners
        graphics = foo.createGraphics();
        try {
            graphics.setComposite(AlphaComposite.SrcIn);
            graphics.drawImage(dest, 0, 0, null);
        }
        finally {
            graphics.dispose();
        }

        // Draw it all back to dest
        g = dest.createGraphics();
        try {
            g.setComposite(AlphaComposite.SrcOver);
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.drawImage(foo, 0, 0, null);
        }
        finally {
            g.dispose();
        }

        return dest;
    }
1224242
public static function image_resize($src, $dest, $w, $h) {
        $img = getimagesize($src);
        switch ($img[2]) {
            case 1:
                $im_in = imagecreatefromgif($src);
                $im_out = imagecreate($w, $h);
                $bgcolor = imagecolorallocate($im_out, 0, 0, 0);
                $bgcolortrans = ImageColorTransparent($im_out, $bgcolor);
                break;
            case 2:
                $im_in = imagecreatefromjpeg($src);
                $im_out = imagecreatetruecolor($w, $h);
                break;
            case 3:
                $im_in = imagecreatefrompng($src);
                $im_out = imagecreatetruecolor($w, $h);
                imagealphablending($im_out, true);
                imagesavealpha($im_out, true);
                $trans_colour = imagecolorallocatealpha($im_out, 0, 0, 0, 127);
                imagefill($im_out, 0, 0, $trans_colour);
                break;
            default:
                copy($src, $dest);
        }
        if (!$im_in || !$im_out) {
            return false;
        }
        imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $w, $h, $img[0], $img[1]);
        switch ($img[2]) {
            case 1:
                imagegif($im_out, $dest);
                break;
            case 2:
                imagejpeg($im_out, $dest);
                break;
            case 3:
                imagepng($im_out, $dest);
                break;
            default:
                return -5;  //保存失败
        }
        imagedestroy($im_out);
        imagedestroy($im_in);
    }
1066167
public static void copy(final Object src, final int srcPos, final Object dest, final int destPos, final int length) {
        if (Array.getLength(src) < srcPos + length) {
            throw new IllegalArgumentException("The size of src array less than " + (srcPos + length));
        }

        if (Array.getLength(dest) < destPos + length) {
            throw new IllegalArgumentException("The size of dest array less than " + (destPos + length));
        }

        System.arraycopy(src, srcPos, dest, destPos, length);
    }
982014
public void toNormalImage(File src, File dest) {
        String command = commandDir + (dest.getName().endsWith(".gif") ? "/gif2webp" : "/dwebp ") + src.getPath() + " -o " + dest.getPath();
        this.executeCommand(command);
    }
1046653
public static String stringToString(String src, String srcfmt, String desfmt) {
        return dateToString(stringToDate(src, srcfmt), desfmt);
    }
1367385
public static BufferedImage copy(BufferedImage src, BufferedImage dest) {
        dest.getGraphics().drawImage(src, 0, 0, null);
        return dest;
    }
334664
public final void compress(ByteBuffer src, ByteBuffer dest) {
    final int cpLen = compress(src, src.position(), src.remaining(), dest, dest.position(), dest.remaining());
    src.position(src.limit());
    dest.position(dest.position() + cpLen);
  }
785508
public final void mDESC() throws RecognitionException {
		try {
			int _type = DESC;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// druidG.g:636:6: ( ( 'DESC' | 'desc' ) )
			// druidG.g:636:8: ( 'DESC' | 'desc' )
			{
			// druidG.g:636:8: ( 'DESC' | 'desc' )
			int alt25=2;
			int LA25_0 = input.LA(1);
			if ( (LA25_0=='D') ) {
				alt25=1;
			}
			else if ( (LA25_0=='d') ) {
				alt25=2;
			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 25, 0, input);
				throw nvae;
			}

			switch (alt25) {
				case 1 :
					// druidG.g:636:9: 'DESC'
					{
					match("DESC"); 

					}
					break;
				case 2 :
					// druidG.g:636:18: 'desc'
					{
					match("desc"); 

					}
					break;

			}

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
891648
public static void copyFiles(File src, File dest) throws IOException {
        if (src.isDirectory()) {
            dest.mkdirs();
            String list[] = src.list();
            for (String fileName : list) {
                String dest1 = dest.getPath() + "/" + fileName;
                String src1 = src.getPath() + "/" + fileName;
                // i.e: avoid .svn directory
                File src1_ = new File(src1);
                File dest1_ = new File(dest1);
                if (!src1_.isHidden()) {
                    copyFiles(src1_, dest1_);
                }
            }
        } else {

            FileInputStream fin = new FileInputStream(src);
            FileOutputStream fout = new FileOutputStream(dest);
            int c;
            while ((c = fin.read()) >= 0) {
                fout.write(c);
            }
            fin.close();
            fout.close();
        }
    }