From fb5c3db157c26462ed5f23d9ad3c6040d248b2fa Mon Sep 17 00:00:00 2001 From: xuchengsheng Date: Tue, 5 Dec 2023 20:40:52 +0800 Subject: [PATCH] spring-dataops-beanWrapper spring-dataops-propertyEditor --- README.md | 2 -- spring-dataops/pom.xml | 2 ++ .../spring-dataops-beanWrapper/README.md | 0 .../spring-dataops-beanWrapper/pom.xml | 14 ++++++++ .../java/com/xcs/spring/BeanWrapperDemo.java | 35 +++++++++++++++++++ .../src/main/java/com/xcs/spring/Company.java | 23 ++++++++++++ .../main/java/com/xcs/spring/Employee.java | 24 +++++++++++++ .../spring-dataops-propertyEditor/README.md | 0 .../spring-dataops-propertyEditor/pom.xml | 14 ++++++++ .../com/xcs/spring/PropertyEditorDemo.java | 8 +++++ 10 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 spring-dataops/spring-dataops-beanWrapper/README.md create mode 100644 spring-dataops/spring-dataops-beanWrapper/pom.xml create mode 100644 spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/BeanWrapperDemo.java create mode 100644 spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Company.java create mode 100644 spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Employee.java create mode 100644 spring-dataops/spring-dataops-propertyEditor/README.md create mode 100644 spring-dataops/spring-dataops-propertyEditor/pom.xml create mode 100644 spring-dataops/spring-dataops-propertyEditor/src/main/java/com/xcs/spring/PropertyEditorDemo.java diff --git a/README.md b/README.md index f313079..86e3265 100644 --- a/README.md +++ b/README.md @@ -313,11 +313,9 @@ 📢 想要一起加入我们的精彩微信群吗?跟着以下简单步骤: 1️⃣ **扫描我的二维码**:使用微信的扫一扫功能,扫描下方的二维码,将我添加为你的好友。 -
logo
- 2️⃣ **等待好友请求被接受**:一旦你的好友请求被接受,你将收到一份群组邀请。 3️⃣ **点击邀请链接**:打开邀请链接,立即加入我们的精彩群组! diff --git a/spring-dataops/pom.xml b/spring-dataops/pom.xml index baed57f..2a43ba5 100644 --- a/spring-dataops/pom.xml +++ b/spring-dataops/pom.xml @@ -13,6 +13,8 @@ pom spring-dataops-validator + spring-dataops-beanWrapper + spring-dataops-propertyEditor \ No newline at end of file diff --git a/spring-dataops/spring-dataops-beanWrapper/README.md b/spring-dataops/spring-dataops-beanWrapper/README.md new file mode 100644 index 0000000..e69de29 diff --git a/spring-dataops/spring-dataops-beanWrapper/pom.xml b/spring-dataops/spring-dataops-beanWrapper/pom.xml new file mode 100644 index 0000000..8937cf1 --- /dev/null +++ b/spring-dataops/spring-dataops-beanWrapper/pom.xml @@ -0,0 +1,14 @@ + + + + spring-dataops + com.xcs.spring + 0.0.1-SNAPSHOT + + + 4.0.0 + spring-dataops-beanWrapper + + \ No newline at end of file diff --git a/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/BeanWrapperDemo.java b/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/BeanWrapperDemo.java new file mode 100644 index 0000000..79e1233 --- /dev/null +++ b/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/BeanWrapperDemo.java @@ -0,0 +1,35 @@ +package com.xcs.spring; + +import org.springframework.beans.BeanWrapper; +import org.springframework.beans.BeanWrapperImpl; + +import java.beans.*; + +public class BeanWrapperDemo { + + public static void main(String[] args) { + // ok, let's create the director and tie it to the company: + BeanWrapper employee = new BeanWrapperImpl(new Employee()); + employee.setPropertyValue("name", "Jim Stravinsky"); + employee.setPropertyValue("salary", "100"); + + BeanWrapper company = new BeanWrapperImpl(new Company()); + company.setPropertyValue("name", "Some Company Inc."); + company.setPropertyValue("managingDirector", employee.getWrappedInstance()); + + // retrieving the salary of the managingDirector through the company + Float salary = (Float) company.getPropertyValue("managingDirector.salary"); + + System.out.println("salary = " + salary); + + System.out.println("company.getPropertyDescriptors() = " + company.getPropertyDescriptors()); + + try { + BeanInfo beanInfo = Introspector.getBeanInfo(Employee.class); + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + System.out.println("beanInfo.getBeanDescriptor() = " + propertyDescriptors); + } catch (IntrospectionException e) { + e.printStackTrace(); + } + } +} diff --git a/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Company.java b/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Company.java new file mode 100644 index 0000000..372b65b --- /dev/null +++ b/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Company.java @@ -0,0 +1,23 @@ +package com.xcs.spring; + +public class Company { + + private String name; + private Employee managingDirector; + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public Employee getManagingDirector() { + return this.managingDirector; + } + + public void setManagingDirector(Employee managingDirector) { + this.managingDirector = managingDirector; + } +} diff --git a/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Employee.java b/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Employee.java new file mode 100644 index 0000000..38105a2 --- /dev/null +++ b/spring-dataops/spring-dataops-beanWrapper/src/main/java/com/xcs/spring/Employee.java @@ -0,0 +1,24 @@ +package com.xcs.spring; + +public class Employee { + + private String name; + + private float salary; + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public float getSalary() { + return salary; + } + + public void setSalary(float salary) { + this.salary = salary; + } +} diff --git a/spring-dataops/spring-dataops-propertyEditor/README.md b/spring-dataops/spring-dataops-propertyEditor/README.md new file mode 100644 index 0000000..e69de29 diff --git a/spring-dataops/spring-dataops-propertyEditor/pom.xml b/spring-dataops/spring-dataops-propertyEditor/pom.xml new file mode 100644 index 0000000..71c0c1d --- /dev/null +++ b/spring-dataops/spring-dataops-propertyEditor/pom.xml @@ -0,0 +1,14 @@ + + + + spring-dataops + com.xcs.spring + 0.0.1-SNAPSHOT + + + 4.0.0 + spring-dataops-propertyEditor + + \ No newline at end of file diff --git a/spring-dataops/spring-dataops-propertyEditor/src/main/java/com/xcs/spring/PropertyEditorDemo.java b/spring-dataops/spring-dataops-propertyEditor/src/main/java/com/xcs/spring/PropertyEditorDemo.java new file mode 100644 index 0000000..a39ec1f --- /dev/null +++ b/spring-dataops/spring-dataops-propertyEditor/src/main/java/com/xcs/spring/PropertyEditorDemo.java @@ -0,0 +1,8 @@ +package com.xcs.spring; + +public class PropertyEditorDemo { + + public static void main(String[] args) { + + } +}