Skip to content

Commit

Permalink
2.0.7
Browse files Browse the repository at this point in the history
1.Fix the bug where the clone API only returns the original object
2.Support maven-shade-plugin
3.Add new parameters for clone, setProperty, and getProperty for more
complex scenarios
  • Loading branch information
org-kepe committed Dec 6, 2023
1 parent c795788 commit 86328f4
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 255 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ DemoConsumer consumer = BeancpUtil.copy(user, DemoConsumer.class,BeancpUtil.newC
| @BeancpProperty | It can be placed on the parameters of methods, fields, and constructors, and set one or more other names. It can also be placed on a non get set method, and the beancp framework will automatically parse it as a get set method |
### clone
~~~Java
//clone object
//clone object
//If the object is cloneable, the clone method will be called, and if not, it will be copied by property.
DemoUser user = ...
DemoUser user2 = BeancpUtil.clone(user);
~~~
Expand Down
2 changes: 1 addition & 1 deletion beancp-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dependency>
<groupId>io.github.org-kepe</groupId>
<artifactId>beancp</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void test1() {

Assert.assertEquals(user.getId(), user2.getId());
Assert.assertTrue(user2.isLive());
Assert.assertFalse(user==user2);
}
@Test
public void test2() {
Expand Down
2 changes: 1 addition & 1 deletion beancp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.org-kepe</groupId>
<artifactId>beancp</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
<packaging>jar</packaging>
<name>beancp</name>
<url>https://github.com/org-kepe/beancp</url>
Expand Down
107 changes: 97 additions & 10 deletions beancp/src/main/java/org/kepe/beancp/BeancpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ public static BeancpContext newContext() {
}
/**
* clone object
* @param <T>
* @param obj
* @return
*/
public static <T> T clone(T obj) {
return clone(obj,null);
return BeancpTool.clone(obj, null, null, null);
}
/**
* clone object
Expand All @@ -115,7 +116,28 @@ public static <T> T clone(T obj) {
* @return
*/
public static <T> T clone(T obj,Type type) {
return BeancpTool.clone(obj, type);
return BeancpTool.clone(obj, type, null, null);
}
/**
* clone object
* @param <T>
* @param obj
* @param feature
* @return
*/
public static <T> T clone(T obj,BeancpFeature feature) {
return BeancpTool.clone(obj, null, feature, null);
}
/**
* clone object
* @param <T>
* @param obj
* @param type
* @param feature
* @return
*/
public static <T> T clone(T obj,Type type,BeancpFeature feature) {
return BeancpTool.clone(obj, type, feature, null);
}
/**
* Setting Property Value for Javabeans
Expand All @@ -124,7 +146,17 @@ public static <T> T clone(T obj,Type type) {
* @param value
*/
public static void setProperty(Object obj,String key,Object value) {
BeancpTool.setProperty(null, obj, key, value);
BeancpTool.setProperty(null, obj, key, value,null,null);
}
/**
* Setting Property Value for Javabeans
* @param obj
* @param key
* @param value
* @param feature
*/
public static void setProperty(Object obj,String key,Object value,BeancpFeature feature) {
BeancpTool.setProperty(null, obj, key, value,feature,null);
}
/**
* Setting Property Value for Javabeans
Expand All @@ -134,7 +166,18 @@ public static void setProperty(Object obj,String key,Object value) {
* @param value
*/
public static void setProperty(Type type,Object obj,String key,Object value) {
BeancpTool.setProperty(type, obj, key, value);
BeancpTool.setProperty(type, obj, key, value,null,null);
}
/**
* Setting Property Value for Javabeans
* @param type
* @param obj
* @param key
* @param value
* @param feature
*/
public static void setProperty(Type type,Object obj,String key,Object value,BeancpFeature feature) {
BeancpTool.setProperty(type, obj, key, value,feature,null);
}
/**
* Obtain Javabean property value
Expand All @@ -143,7 +186,17 @@ public static void setProperty(Type type,Object obj,String key,Object value) {
* @return
*/
public static Object getProperty(Object obj,String key) {
return BeancpTool.getProperty(null, obj, key, null);
return BeancpTool.getProperty(null, obj, key, null,null,null);
}
/**
* Obtain Javabean property value
* @param obj
* @param key
* @param feature
* @return
*/
public static Object getProperty(Object obj,String key,BeancpFeature feature) {
return BeancpTool.getProperty(null, obj, key, null,feature,null);
}
/**
* Obtain Javabean property value
Expand All @@ -153,7 +206,18 @@ public static Object getProperty(Object obj,String key) {
* @return
*/
public static Object getProperty(Object obj,String key,Type valueType) {
return BeancpTool.getProperty(null, obj, key, valueType);
return BeancpTool.getProperty(null, obj, key, valueType,null,null);
}
/**
* Obtain Javabean property value
* @param obj
* @param key
* @param valueType
* @param feature
* @return
*/
public static Object getProperty(Object obj,String key,Type valueType,BeancpFeature feature) {
return BeancpTool.getProperty(null, obj, key, valueType,feature,null);
}
/**
* Obtain Javabean property value
Expand All @@ -165,7 +229,7 @@ public static Object getProperty(Object obj,String key,Type valueType) {
*/
@SuppressWarnings("unchecked")
public static <T> T getProperty(Object obj,String key,Class<T> valueType) {
return (T) BeancpTool.getProperty(null, obj, key, valueType);
return (T) BeancpTool.getProperty(null, obj, key, valueType,null,null);
}
/**
* Obtain Javabean property value
Expand All @@ -175,7 +239,18 @@ public static <T> T getProperty(Object obj,String key,Class<T> valueType) {
* @return
*/
public static Object getProperty(Type type,Object obj,String key) {
return BeancpTool.getProperty(type, obj, key, null);
return BeancpTool.getProperty(type, obj, key, null,null,null);
}
/**
* Obtain Javabean property value
* @param type
* @param obj
* @param key
* @param feature
* @return
*/
public static Object getProperty(Type type,Object obj,String key,BeancpFeature feature) {
return BeancpTool.getProperty(type, obj, key, null,feature,null);
}
/**
* Obtain Javabean property value
Expand All @@ -186,7 +261,19 @@ public static Object getProperty(Type type,Object obj,String key) {
* @return
*/
public static Object getProperty(Type type,Object obj,String key,Type valueType) {
return BeancpTool.getProperty(type, obj, key, valueType);
return BeancpTool.getProperty(type, obj, key, valueType,null,null);
}
/**
* Obtain Javabean property value
* @param type
* @param obj
* @param key
* @param valueType
* @param feature
* @return
*/
public static Object getProperty(Type type,Object obj,String key,Type valueType,BeancpFeature feature) {
return BeancpTool.getProperty(type, obj, key, valueType,feature,null);
}
/**
* Obtain Javabean property value
Expand All @@ -198,7 +285,7 @@ public static Object getProperty(Type type,Object obj,String key,Type valueType)
*/
@SuppressWarnings("unchecked")
public static <T> T getProperty(Type type,Object obj,String key,Class<T> valueType) {
return (T) BeancpTool.getProperty(type, obj, key, valueType);
return (T) BeancpTool.getProperty(type, obj, key, valueType,null,null);
}

/**
Expand Down
Loading

0 comments on commit 86328f4

Please sign in to comment.