├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src
├── main
└── java
│ └── com
│ └── tuyang
│ └── beanutils
│ ├── BeanCopier.java
│ ├── BeanCopyConvertor.java
│ ├── BeanCopyUtils.java
│ ├── annotation
│ ├── BeanCopySource.java
│ ├── CopyCollection.java
│ ├── CopyFeature.java
│ └── CopyProperty.java
│ ├── config
│ └── BeanCopyConfig.java
│ ├── exception
│ └── BeanCopyException.java
│ └── internal
│ ├── cache
│ ├── BeanCopyCache.java
│ └── BeanCopyPropertyItem.java
│ ├── convertors
│ ├── ArrayConvertorFactory.java
│ ├── BoolArrayConvertor.java
│ ├── BoolObjectArrayConvertor.java
│ ├── ByteArrayConvertor.java
│ ├── ByteObjectArrayConvertor.java
│ ├── CharArrayConvertor.java
│ ├── CharObjectArrayConvertor.java
│ ├── DoubleArrayConvertor.java
│ ├── DoubleObjectArrayConvertor.java
│ ├── EnumToEnumArrayConvertor.java
│ ├── EnumToStringArrayConvertor.java
│ ├── EnumToStringConvertor.java
│ ├── FloatArrayConvertor.java
│ ├── FloatObjectArrayConvertor.java
│ ├── IntArrayConvertor.java
│ ├── IntObjectArrayConvertor.java
│ ├── ListToEnumArrayConvertor.java
│ ├── LongArrayConvertor.java
│ ├── LongObjectArrayConvertor.java
│ ├── ObjectArrayConvertor.java
│ ├── ObjectToEnumConvertor.java
│ ├── ObjectToStringArrayConvertor.java
│ ├── ObjectToStringConvertor.java
│ ├── ShortArrayConvertor.java
│ ├── ShortObjectArrayConvertor.java
│ └── StringToEnumArrayConvertor.java
│ ├── dump
│ └── BeanCopyDump.java
│ ├── factory
│ └── BeanCopierFactory.java
│ ├── javassist
│ └── JavassistBeanCopyFactory.java
│ ├── logger
│ └── Logger.java
│ ├── reflect
│ ├── ReflactBeanCopyFactory.java
│ └── ReflectBeanCopy.java
│ └── utils
│ ├── InstanceUtils.java
│ └── PropertyUtils.java
└── test
└── java
└── com
└── tuyang
└── test
├── perftest
├── BeanCopyInterface.java
├── FromBean.java
├── LoopTest.java
├── TestPerformance.java
└── ToBean.java
├── testAnnotation
├── FromBean.java
├── Test03.java
└── ToBean.java
├── testAnnotation2
├── FromBean.java
├── FromBean2.java
├── Test04.java
├── ToBean.java
└── ToBean2.java
├── testArray
├── FromBean.java
├── FromBean2.java
├── Test08.java
├── ToBean.java
└── ToBean2.java
├── testArrayList
├── FromBean.java
├── FromBean2.java
├── Test08.java
├── ToBean.java
└── ToBean2.java
├── testArrayList2
├── FromBean.java
├── TestArrayList.java
└── ToBean.java
├── testBasic
├── FromBean.java
├── Test01.java
└── ToBean.java
├── testBeanToString
├── FromBean.java
├── FromBean2.java
├── Test03.java
└── ToBean.java
├── testCollection
├── FromBean.java
├── FromBean2.java
├── Test05.java
├── ToBean.java
└── ToBean2.java
├── testConvertor
├── FromBean.java
├── GendorConvertor.java
├── MyEnum.java
├── MyEnumConvertor.java
├── Test11.java
└── ToBean.java
├── testEnum
├── FromBean.java
├── MyEnum.java
├── Test08.java
└── ToBean.java
├── testEnum2
├── FromBean.java
├── Inside.java
├── MyEnum.java
├── Test08.java
└── ToBean.java
├── testFeatureIgnorePimitive
├── FromBean.java
├── TestFeatureIgnorePimitive.java
├── ToBean.java
└── ToBeanOption.java
├── testIgnoreAll
├── FromBean.java
├── FromBean2.java
├── TestIgnoreAll.java
└── ToBean.java
├── testInheritance
├── FromBean.java
├── FromBeanBase.java
├── Test09.java
├── ToBean.java
└── ToBeanBase.java
├── testInheritance2
├── FromBean.java
├── FromBeanBase.java
├── Test10.java
├── ToBean.java
├── ToBeanBase.java
└── ToBeanOption.java
├── testMisc
├── DateConvertor.java
├── FromBean.java
├── FromBean2.java
├── FromBean3.java
├── FromBean4.java
├── Test12.java
├── ToBean.java
├── ToBean2.java
├── ToBean3.java
└── ToBean4.java
├── testMultiThread
├── FromBean.java
├── StringToIntegerConverter.java
├── TestMultiThread.java
└── ToBean.java
├── testOption
├── FromBean.java
├── Test07.java
├── ToBean.java
└── ToBeanOption.java
├── testPrimitive
├── FromBean.java
├── Test02.java
└── ToBean.java
├── testRecursion
├── FromBean.java
├── FromBean2.java
├── FromBean3.java
├── FromBean4.java
├── FromBean5.java
├── FromBean6.java
├── FromBean7.java
├── FromBean8.java
├── Test06.java
└── ToBean.java
└── testRecursion2
├── FromBean.java
├── TestRecursion.java
└── ToBean.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 | /target/
24 | /.classpath
25 | /.project
26 | /.settings/org.eclipse.core.resources.prefs
27 | /.settings/org.eclipse.jdt.core.prefs
28 | /.settings/org.eclipse.m2e.core.prefs
29 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 | com.github.yangtu222
6 | BeanUtils
7 | BeanUtils
8 | 1.0.11
9 | BeanUtils library is a Java bean copy utility with powerful functionality and high performance.
10 | https://github.com/yangtu222/BeanUtils
11 |
12 |
13 | UTF-8
14 | UTF-8
15 | 1.5.4.RELEASE
16 | 1.7
17 | 1.7
18 | UTF-8
19 |
20 | 3.0.1
21 | 2.10.4
22 | 2.5.3
23 | 1.6
24 |
25 |
26 |
27 | scm:git:https://github.com/yangtu222/BeanUtils.git
28 | scm:git:https://github.com/yangtu222/BeanUtils.git
29 | https://github.com/yangtu222/BeanUtils.git
30 | v1.0.11
31 |
32 |
33 |
34 |
35 | release
36 |
37 |
38 |
39 | maven-source-plugin
40 | ${maven.source.plugin.version}
41 |
42 |
43 | package
44 |
45 | jar-no-fork
46 |
47 |
48 |
49 |
50 |
51 | org.apache.maven.plugins
52 | maven-javadoc-plugin
53 | ${maven.javadoc.plugin.version}
54 |
55 | com.tuyang.beanutils.internal
56 |
57 |
58 |
59 | package
60 |
61 | jar
62 |
63 |
64 |
65 |
66 |
67 | maven-release-plugin
68 | ${maven.release.plugin.version}
69 | true
70 |
71 |
72 | org.apache.maven.plugins
73 | maven-gpg-plugin
74 | ${maven.gpg.plugin.version}
75 |
76 |
77 | verify
78 |
79 | sign
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | ${project.artifactId}-${project.version}
91 |
92 |
93 | org.sonatype.plugins
94 | nexus-staging-maven-plugin
95 | 1.6.3
96 | true
97 |
98 | ossrh
99 | https://oss.sonatype.org/
100 | true
101 |
102 |
103 |
104 | org.apache.maven.plugins
105 | maven-compiler-plugin
106 | 3.6.1
107 |
108 |
109 | org.apache.maven.plugins
110 | maven-source-plugin
111 | 2.2.1
112 |
113 |
114 | attach-sources
115 |
116 | jar-no-fork
117 |
118 |
119 |
120 |
121 |
122 | org.apache.maven.plugins
123 | maven-javadoc-plugin
124 | 2.9.1
125 |
126 |
127 | attach-javadocs
128 |
129 | jar
130 |
131 |
132 |
133 |
134 |
135 | org.apache.maven.plugins
136 | maven-gpg-plugin
137 | 1.5
138 |
139 |
140 | sign-artifacts
141 | verify
142 |
143 | sign
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 | org.springframework.boot
155 | spring-boot-dependencies
156 | 1.5.4.RELEASE
157 | pom
158 | import
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 | org.javassist
168 | javassist
169 |
170 |
171 |
172 | org.springframework.boot
173 | spring-boot-starter
174 | test
175 |
176 |
177 |
178 |
179 | org.apache.commons
180 | commons-lang3
181 | 3.5
182 | test
183 |
184 |
185 |
186 |
187 | org.apache.commons
188 | commons-collections4
189 | 4.1
190 | test
191 |
192 |
193 |
194 |
195 | commons-beanutils
196 | commons-beanutils
197 | test
198 |
199 |
200 |
201 |
202 | net.sf.ezmorph
203 | ezmorph
204 | 1.0.6
205 | test
206 |
207 |
208 |
209 | junit
210 | junit
211 | test
212 |
213 |
214 |
215 |
216 |
217 |
218 | Tu Yang
219 | yangtu222@hotmail.com
220 |
221 |
222 |
223 |
224 |
225 | The Apache License, Version 2.0
226 | http://www.apache.org/licenses/LICENSE-2.0.txt
227 |
228 |
229 |
230 |
231 |
232 | ossrh
233 | https://oss.sonatype.org/content/repositories/snapshots
234 |
235 |
236 | ossrh
237 | https://oss.sonatype.org/service/local/staging/deploy/maven2
238 |
239 |
240 |
241 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/BeanCopier.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils;
31 |
32 | /**
33 | * This interface is to do the real bean copy.
34 | *
35 | */
36 | public interface BeanCopier {
37 |
38 | /**
39 | * Copy sourceObject properties to targetObject properties.
40 | * @param sourceObject The source object which want to be copied from.
41 | * @param targetObject The target object which want to be copied to.
42 | * @return targetObject The target object is returned.
43 | *
44 | * Exception: if error, RuntimeException will be thrown, and can be BeanCopyException.
45 | */
46 | public Object copyBean(Object sourceObject, Object targetObject );
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/BeanCopyConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils;
31 | /**
32 | * This interface is to do custom data conversion.
33 | *
34 | * @param The Source Type.
35 | * @param The Target Type.
36 | */
37 | public interface BeanCopyConvertor {
38 |
39 | /**
40 | * This function is to do custom data conversion.
41 | * @param object : Source Object.
42 | * @return Converted Target Object.
43 | */
44 | public T convertTo(S object);
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/annotation/BeanCopySource.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.annotation;
31 |
32 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
33 | import static java.lang.annotation.ElementType.TYPE;
34 |
35 | import java.lang.annotation.Retention;
36 | import java.lang.annotation.Target;
37 |
38 | @Retention(RUNTIME)
39 | @Target(TYPE)
40 | public @interface BeanCopySource {
41 |
42 | /**
43 | * Specify the source class type.
44 | * @return The source class type.
45 | */
46 | Class> source();
47 |
48 | CopyFeature[] features() default {};
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/annotation/CopyCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.annotation;
31 |
32 | import static java.lang.annotation.ElementType.FIELD;
33 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
34 |
35 | import java.lang.annotation.Documented;
36 | import java.lang.annotation.Retention;
37 | import java.lang.annotation.Target;
38 |
39 | @Retention(RUNTIME)
40 | @Target(FIELD)
41 | @Documented
42 | public @interface CopyCollection {
43 |
44 | /**
45 | * The property name in source object that want to be copied from.
46 | *
Note:
47 | *
"" (empty string, or null): means the property name is same to source object.
48 | * a.b: means the source value is coming from source object's property a's property b.
49 | * @return the property name which will be copied from.
50 | */
51 | String property() default "";
52 |
53 | /**
54 | * Specify this property will be ignored when do bean copy.
55 | * @return true is ignored.
56 | */
57 | boolean ignored() default false;
58 |
59 | /**
60 | * Specify the collection's template class type.
61 | * @return The colleciton's template class type.
62 | */
63 | Class> targetClass();
64 |
65 | /**
66 | * Specify the optionClass when coping when targetClass is a Java bean class.
67 | * @return option class.
68 | */
69 | Class> optionClass() default void.class;
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/annotation/CopyFeature.java:
--------------------------------------------------------------------------------
1 | package com.tuyang.beanutils.annotation;
2 |
3 | public enum CopyFeature {
4 | IGNORE_PRIMITIVE_NULL_SOURCE_VALUE,
5 | IGNORE_ALL_NULL_SOURCE_VALUE,
6 | IGNORE_ENUM_CONVERT_EXCEPTION,
7 | ENABLE_JAVA_BEAN_TO_STRING,
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/annotation/CopyProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.annotation;
31 |
32 | import static java.lang.annotation.ElementType.FIELD;
33 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
34 |
35 | import java.lang.annotation.Documented;
36 | import java.lang.annotation.Retention;
37 | import java.lang.annotation.Target;
38 |
39 | @Retention(RUNTIME)
40 | @Target(FIELD)
41 | @Documented
42 | public @interface CopyProperty {
43 |
44 | /**
45 | * The property name in source object that want to be copied from.
46 | *
Note:
47 | *
"" (empty string, or null): means the property name is same to source object.
48 | * a.b: means the source value is coming from source object's property a's property b.
49 | * @return the property name which will be copied from.
50 | */
51 | String property() default "";
52 |
53 | /**
54 | * Specify this property will be ignored when do bean copy.
55 | * @return true is ignored.
56 | */
57 | boolean ignored() default false;
58 |
59 | /**
60 | * The data convertor of this property. The convertor must be BeanCopyConvertor type.
61 | * @return convertor's class type.
62 | *
63 | * @see com.tuyang.beanutils.BeanCopyConvertor
64 | */
65 | Class> convertor() default void.class ;
66 |
67 | /**
68 | * Specify the optionClass when coping when this property is a Java bean class.
69 | * @return option class.
70 | */
71 | Class> optionClass() default void.class;
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/config/BeanCopyConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.config;
31 |
32 | import java.util.ArrayDeque;
33 | import java.util.ArrayList;
34 | import java.util.HashSet;
35 |
36 | import com.tuyang.beanutils.internal.cache.BeanCopyCache;
37 | import com.tuyang.beanutils.internal.factory.BeanCopierFactory;
38 | import com.tuyang.beanutils.internal.javassist.JavassistBeanCopyFactory;
39 | import com.tuyang.beanutils.internal.logger.Logger;
40 | import com.tuyang.beanutils.internal.reflect.ReflactBeanCopyFactory;
41 |
42 | public class BeanCopyConfig {
43 |
44 | public static enum DumpOption {
45 | AutoDumpNone,
46 | AutoDumpAtFirstCopy,
47 | AutoDumpAlways
48 | }
49 |
50 | private static BeanCopyConfig INSTANCE = new BeanCopyConfig();
51 |
52 | private int logLevel = Logger.LogLevelWarn;
53 |
54 | private Class> setClass = HashSet.class;
55 | private Class> listClass = ArrayList.class;
56 | private Class> queueClass = ArrayDeque.class;
57 | private Class> dequeClass = ArrayDeque.class;
58 |
59 | private Class extends BeanCopierFactory> beanCopyFactory = JavassistBeanCopyFactory.class;
60 | // private Class extends BeanCopierFactory> beanCopyFactory = ReflactBeanCopyFactory.class;
61 |
62 | private DumpOption dumpOption = DumpOption.AutoDumpAtFirstCopy;
63 |
64 | private ClassLoader classLoader = null;
65 |
66 | public ClassLoader getClassLoader() {
67 | return classLoader;
68 | }
69 |
70 | public void setClassLoader(ClassLoader classLoader) {
71 | this.classLoader = classLoader;
72 | }
73 |
74 | public static BeanCopyConfig instance() {
75 | return INSTANCE;
76 | }
77 |
78 | public static void setBeanCopyConfig(BeanCopyConfig beanCopyConfig) {
79 | if( beanCopyConfig == null )
80 | beanCopyConfig = new BeanCopyConfig();
81 | BeanCopyConfig.INSTANCE = beanCopyConfig;
82 | BeanCopyCache.setBeanCopyConfig(beanCopyConfig);
83 | }
84 |
85 | public int getLogLevel() {
86 | return logLevel;
87 | }
88 |
89 | public void setLogLevel(int logLevel) {
90 | this.logLevel = logLevel;
91 | }
92 |
93 | public Class> getSetClass() {
94 | return setClass;
95 | }
96 |
97 | public void setSetClass(Class> setClass) {
98 | this.setClass = setClass;
99 | }
100 |
101 | public Class> getListClass() {
102 | return listClass;
103 | }
104 |
105 | public void setListClass(Class> listClass) {
106 | this.listClass = listClass;
107 | }
108 |
109 | public Class extends BeanCopierFactory> getBeanCopyFactory() {
110 | return beanCopyFactory;
111 | }
112 |
113 | public void setBeanCopyFactory(Class extends BeanCopierFactory> beanCopyFactory) {
114 | this.beanCopyFactory = beanCopyFactory;
115 | }
116 |
117 | public Class> getQueueClass() {
118 | return queueClass;
119 | }
120 |
121 | public void setQueueClass(Class> queueClass) {
122 | this.queueClass = queueClass;
123 | }
124 |
125 | public Class> getDequeClass() {
126 | return dequeClass;
127 | }
128 |
129 | public void setDequeClass(Class> dequeClass) {
130 | this.dequeClass = dequeClass;
131 | }
132 |
133 | public DumpOption getDumpOption() {
134 | return dumpOption;
135 | }
136 |
137 | public void setDumpOption(DumpOption dumpOption) {
138 | this.dumpOption = dumpOption;
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/exception/BeanCopyException.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.exception;
31 |
32 | /**
33 | * Thrown when generating BeanCopier or new instance in BanCopyUtils methods.
34 | *
35 | **/
36 | public class BeanCopyException extends RuntimeException {
37 |
38 | private static final long serialVersionUID = 9055425084609925821L;
39 |
40 | public BeanCopyException(String message){
41 | super(message);
42 | }
43 |
44 | public BeanCopyException( String message, Throwable cause){
45 | super(message,cause);
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/cache/BeanCopyPropertyItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.cache;
31 |
32 | import java.lang.reflect.Method;
33 |
34 | import com.tuyang.beanutils.BeanCopyConvertor;
35 | import com.tuyang.beanutils.annotation.CopyFeature;
36 |
37 | public class BeanCopyPropertyItem {
38 |
39 | public String propertyName = null;
40 | public Method[] readMethods = null;
41 | public Method writeMethod = null;
42 |
43 | public boolean isCollection = false;
44 | public boolean useBeanCopy = false;
45 |
46 | public Class> collectionClass = null;
47 | public Class> optionClass = null;
48 |
49 | public Class> convertorClass = null;
50 | @SuppressWarnings("rawtypes")
51 | public BeanCopyConvertor convertorObject = null;
52 |
53 | public CopyFeature[] features;
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/ArrayConvertorFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | public class ArrayConvertorFactory {
35 |
36 | @SuppressWarnings("rawtypes")
37 | public static BeanCopyConvertor getArrayConvertor(Class> methodSourceType, Class> methodTargetType, Class> propertyOptionClass) {
38 |
39 | if( !(methodSourceType.isPrimitive() || methodTargetType.isPrimitive() ) ) {
40 | return new ObjectArrayConvertor(methodSourceType, methodTargetType, propertyOptionClass);
41 | }
42 |
43 | if( int.class.equals(methodSourceType) ) {
44 | return new IntArrayConvertor();
45 | } else if( boolean.class.equals(methodSourceType) ) {
46 | return new BoolArrayConvertor();
47 | } else if( byte.class.equals(methodSourceType) ) {
48 | return new ByteArrayConvertor();
49 | } else if( char.class.equals(methodSourceType) ) {
50 | return new CharArrayConvertor();
51 | } else if( short.class.equals(methodSourceType) ) {
52 | return new ShortArrayConvertor();
53 | } else if( long.class.equals(methodSourceType) ) {
54 | return new LongArrayConvertor();
55 | } else if( float.class.equals(methodSourceType) ) {
56 | return new FloatArrayConvertor();
57 | } else if( double.class.equals(methodSourceType) ) {
58 | return new DoubleArrayConvertor();
59 | } else if( Integer.class.equals(methodSourceType) ) {
60 | return new IntObjectArrayConvertor();
61 | } else if( Boolean.class.equals(methodSourceType) ) {
62 | return new BoolObjectArrayConvertor();
63 | } else if( Character.class.equals(methodSourceType) ) {
64 | return new CharObjectArrayConvertor();
65 | } else if( Byte.class.equals(methodSourceType) ) {
66 | return new ByteObjectArrayConvertor();
67 | } else if( Short.class.equals(methodSourceType) ) {
68 | return new ShortObjectArrayConvertor();
69 | } else if( Long.class.equals(methodSourceType) ) {
70 | return new LongObjectArrayConvertor();
71 | } else if( Float.class.equals(methodSourceType) ) {
72 | return new FloatObjectArrayConvertor();
73 | } else if( Double.class.equals(methodSourceType) ) {
74 | return new DoubleObjectArrayConvertor();
75 | }
76 |
77 | return null;
78 |
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/BoolArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class BoolArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | boolean[] array = (boolean[])object;
40 | Boolean[] retObject = new Boolean[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = Boolean.valueOf(array[i]);
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/BoolObjectArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class BoolObjectArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | Boolean[] array = (Boolean[])object;
40 | boolean[] retObject = new boolean[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = array[i].booleanValue();
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/ByteArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class ByteArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | byte[] array = (byte[])object;
40 | Byte[] retObject = new Byte[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = Byte.valueOf(array[i]);
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/ByteObjectArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class ByteObjectArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | Byte[] array = (Byte[]) object;
40 | byte[] retObject = new byte[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = array[i].byteValue();
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/CharArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class CharArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | char[] array = (char[])object;
40 | Character[] retObject = new Character[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = Character.valueOf(array[i]);
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/CharObjectArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class CharObjectArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | Character[] array = (Character[]) object;
40 | char[] retObject = new char[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = array[i].charValue();
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/DoubleArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class DoubleArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | double[] array = (double[]) object;
40 | Double[] retObject = new Double[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = Double.valueOf(array[i]);
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/DoubleObjectArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class DoubleObjectArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | Double[] array = (Double[]) object;
40 | double[] retObject = new double[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = array[i].doubleValue();
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/EnumToEnumArrayConvertor.java:
--------------------------------------------------------------------------------
1 | package com.tuyang.beanutils.internal.convertors;
2 |
3 | import com.tuyang.beanutils.BeanCopyConvertor;
4 |
5 | @SuppressWarnings("rawtypes")
6 | public class EnumToEnumArrayConvertor implements BeanCopyConvertor {
7 |
8 | @Override
9 | public Enum[] convertTo(Enum[] object) {
10 | if( object == null )
11 | return null;
12 | return object.clone();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/EnumToStringArrayConvertor.java:
--------------------------------------------------------------------------------
1 | package com.tuyang.beanutils.internal.convertors;
2 |
3 | import com.tuyang.beanutils.BeanCopyConvertor;
4 |
5 | @SuppressWarnings("rawtypes")
6 | public class EnumToStringArrayConvertor implements BeanCopyConvertor {
7 |
8 | @Override
9 | public String[] convertTo(Enum[] object) {
10 | if( object == null )
11 | return null;
12 | String[] retList = new String[object.length];
13 | int i =0;
14 | for( Enum enum1 : object ) {
15 | retList[i++] = enum1.toString();
16 | }
17 | return retList;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/EnumToStringConvertor.java:
--------------------------------------------------------------------------------
1 | package com.tuyang.beanutils.internal.convertors;
2 |
3 | import com.tuyang.beanutils.BeanCopyConvertor;
4 |
5 | @SuppressWarnings("rawtypes")
6 | public class EnumToStringConvertor implements BeanCopyConvertor {
7 |
8 | @Override
9 | public String convertTo(Enum object) {
10 | return object.toString();
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/FloatArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class FloatArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | float[] array = (float[]) object;
40 | Float[] retObject = new Float[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = Float.valueOf(array[i]);
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/FloatObjectArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class FloatObjectArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | Float[] array = (Float[]) object;
40 | float[] retObject = new float[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = array[i].floatValue();
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/IntArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class IntArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | int[] array = (int[])object;
40 | Integer[] retObject = new Integer[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = Integer.valueOf(array[i]);
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/IntObjectArrayConvertor.java:
--------------------------------------------------------------------------------
1 | /*
2 | BeanUtils Version 1.0.0
3 |
4 | Created by yangtu222 on 2017.08.05
5 |
6 | Distributed under the permissive zlib License
7 | Get the latest version from here:
8 |
9 | https://github.com/yangtu222/BeanUtils
10 |
11 | This software is provided 'as-is', without any express or implied
12 | warranty. In no event will the authors be held liable for any damages
13 | arising from the use of this software.
14 |
15 | Permission is granted to anyone to use this software for any purpose,
16 | including commercial applications, and to alter it and redistribute it
17 | freely, subject to the following restrictions:
18 |
19 | 1. The origin of this software must not be misrepresented; you must not
20 | claim that you wrote the original software. If you use this software
21 | in a product, an acknowledgment in the product documentation would be
22 | appreciated but is not required.
23 |
24 | 2. Altered source versions must be plainly marked as such, and must not be
25 | misrepresented as being the original software.
26 |
27 | 3. This notice may not be removed or altered from any source distribution.
28 | */
29 |
30 | package com.tuyang.beanutils.internal.convertors;
31 |
32 | import com.tuyang.beanutils.BeanCopyConvertor;
33 |
34 | @SuppressWarnings("rawtypes")
35 | public class IntObjectArrayConvertor implements BeanCopyConvertor {
36 |
37 | @Override
38 | public Object convertTo(Object object) {
39 | Integer[] array = (Integer[]) object;
40 | int[] retObject = new int[array.length];
41 |
42 | for( int i=0;i< array.length; i++) {
43 | retObject[i] = array[i].intValue();
44 | }
45 | return retObject;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/tuyang/beanutils/internal/convertors/ListToEnumArrayConvertor.java:
--------------------------------------------------------------------------------
1 | package com.tuyang.beanutils.internal.convertors;
2 |
3 | import java.lang.reflect.Array;
4 | import java.util.Collection;
5 |
6 | import com.tuyang.beanutils.BeanCopyConvertor;
7 |
8 | @SuppressWarnings("rawtypes")
9 | public class ListToEnumArrayConvertor implements BeanCopyConvertor, Object[]> {
10 |
11 | private Class enumClass;
12 | private boolean throwExceptions;
13 |
14 | public ListToEnumArrayConvertor(Class enumClass, boolean throwExceptions) {
15 | this.enumClass = enumClass;
16 | this.throwExceptions = throwExceptions;
17 | }
18 |
19 | @SuppressWarnings("unchecked")
20 | @Override
21 | public Object[] convertTo(Collection