Subject: [PATCH] 3_jaxb_generate
---
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pom.xml b/pom.xml
--- a/pom.xml	(revision 3a15f50bab09deac93a97f5dcb5fc8c1a4f8e2f4)
+++ b/pom.xml	(date 1695981285196)
@@ -20,6 +20,7 @@
         <spring-shell.version>3.1.3</spring-shell.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <jaxb.version>4.0.3</jaxb.version>
     </properties>
 
     <dependencies>
@@ -27,6 +28,18 @@
             <groupId>org.springframework.shell</groupId>
             <artifactId>spring-shell-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <!--        JAXB-->
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+            <version>${jaxb.version}</version>
+        </dependency>
 
         <!--         Tests-->
         <dependency>
@@ -44,6 +57,20 @@
 
     <build>
         <finalName>docjava</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                        </exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
     </build>
 
     <dependencyManagement>
Index: src/main/java/ru/javaops/docjava/schema/Meals.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/Meals.java b/src/main/java/ru/javaops/docjava/schema/Meals.java
new file mode 100644
--- /dev/null	(date 1695981223642)
+++ b/src/main/java/ru/javaops/docjava/schema/Meals.java	(date 1695981223642)
@@ -0,0 +1,21 @@
+
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.XmlAccessType;
+import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlElement;
+import jakarta.xml.bind.annotation.XmlRootElement;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "Meals", namespace = "http://javaops.ru")
+@Data
+@NoArgsConstructor
+public class Meals {
+    @XmlElement(name = "Meal", namespace = "http://javaops.ru")
+    protected List<Meal> meal = new ArrayList<>();
+}
Index: src/main/java/ru/javaops/docjava/schema/Meal.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/Meal.java b/src/main/java/ru/javaops/docjava/schema/Meal.java
new file mode 100644
--- /dev/null	(date 1695981223638)
+++ b/src/main/java/ru/javaops/docjava/schema/Meal.java	(date 1695981223638)
@@ -0,0 +1,24 @@
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.*;
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "Meal", namespace = "http://javaops.ru")
+@Data
+@NoArgsConstructor
+public class Meal {
+    @XmlValue
+    protected String value;
+    @XmlAttribute(name = "calories", required = true)
+    protected int calories;
+    @XmlAttribute(name = "dateTime", required = true)
+    @XmlJavaTypeAdapter(type = LocalDateTime.class, value = LocalDateTimeXmlAdapter.class)
+    protected LocalDateTime dateTime;
+    @XmlAttribute(name = "excess")
+    protected Boolean excess;
+}
Index: src/main/java/ru/javaops/docjava/schema/LocalDateTimeXmlAdapter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/LocalDateTimeXmlAdapter.java b/src/main/java/ru/javaops/docjava/schema/LocalDateTimeXmlAdapter.java
new file mode 100644
--- /dev/null	(date 1695981223634)
+++ b/src/main/java/ru/javaops/docjava/schema/LocalDateTimeXmlAdapter.java	(date 1695981223634)
@@ -0,0 +1,20 @@
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.adapters.XmlAdapter;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+// https://stackoverflow.com/a/36157446/548473
+public class LocalDateTimeXmlAdapter extends XmlAdapter<String, LocalDateTime> {
+
+    @Override
+    public String marshal(LocalDateTime ldt) {
+        return ldt.format(DateTimeFormatter.ISO_DATE_TIME);
+    }
+
+    @Override
+    public LocalDateTime unmarshal(String str) {
+        return LocalDateTime.parse(str);
+    }
+}
Index: src/main/java/ru/javaops/docjava/schema/UsersWithMeals.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/UsersWithMeals.java b/src/main/java/ru/javaops/docjava/schema/UsersWithMeals.java
new file mode 100644
--- /dev/null	(date 1695981223655)
+++ b/src/main/java/ru/javaops/docjava/schema/UsersWithMeals.java	(date 1695981223655)
@@ -0,0 +1,28 @@
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.XmlAccessType;
+import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlElement;
+import jakarta.xml.bind.annotation.XmlRootElement;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "UsersWithMeals", namespace = "http://javaops.ru")
+@Data
+public class UsersWithMeals {
+
+    @XmlElement(name = "Users", namespace = "http://javaops.ru", required = true)
+    protected UsersWithMeals.Users users;
+
+    @XmlAccessorType(XmlAccessType.FIELD)
+    @Data
+    @NoArgsConstructor
+    public static class Users {
+        @XmlElement(name = "User", namespace = "http://javaops.ru")
+        protected List<User> user = new ArrayList<>();
+    }
+}
Index: src/main/java/ru/javaops/docjava/schema/User.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/User.java b/src/main/java/ru/javaops/docjava/schema/User.java
new file mode 100644
--- /dev/null	(date 1695981223652)
+++ b/src/main/java/ru/javaops/docjava/schema/User.java	(date 1695981223652)
@@ -0,0 +1,33 @@
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.*;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "User", namespace = "http://javaops.ru")
+@Data
+@NoArgsConstructor
+public class User {
+    @XmlAttribute(name = "name", required = true)
+    protected String name;
+    @XmlAttribute(name = "email", required = true)
+    protected String email;
+    @XmlAttribute(name = "password", required = true)
+    protected String password;
+    @XmlAttribute(name = "caloriesPerDay", required = true)
+    protected int caloriesPerDay;
+    @XmlAttribute(name = "registered", required = true)
+    @XmlSchemaType(name = "dateTime")
+    protected Date registered;
+    @XmlAttribute(name = "enabled", required = true)
+    protected boolean enabled;
+    @XmlAttribute(name = "roles")
+    protected List<RoleTypes> roles = new ArrayList<>();
+    @XmlElement(name = "Meals", namespace = "http://javaops.ru")
+    protected Meals meals;
+}
Index: src/main/java/ru/javaops/docjava/schema/RoleTypes.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/RoleTypes.java b/src/main/java/ru/javaops/docjava/schema/RoleTypes.java
new file mode 100644
--- /dev/null	(date 1695981223649)
+++ b/src/main/java/ru/javaops/docjava/schema/RoleTypes.java	(date 1695981223649)
@@ -0,0 +1,29 @@
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.XmlEnum;
+import jakarta.xml.bind.annotation.XmlEnumValue;
+import jakarta.xml.bind.annotation.XmlType;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@XmlType(name = "roleTypes", namespace = "http://javaops.ru")
+@XmlEnum
+@Getter
+@RequiredArgsConstructor
+public enum RoleTypes {
+
+    @XmlEnumValue("admin")
+    ADMIN("admin"),
+    @XmlEnumValue("user")
+    USER("user");
+    private final String value;
+
+    public static RoleTypes fromValue(String v) {
+        for (RoleTypes c : RoleTypes.values()) {
+            if (c.value.equals(v)) {
+                return c;
+            }
+        }
+        throw new IllegalArgumentException(v);
+    }
+}
Index: src/main/java/ru/javaops/docjava/schema/ObjectFactory.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/docjava/schema/ObjectFactory.java b/src/main/java/ru/javaops/docjava/schema/ObjectFactory.java
new file mode 100644
--- /dev/null	(date 1695981223645)
+++ b/src/main/java/ru/javaops/docjava/schema/ObjectFactory.java	(date 1695981223645)
@@ -0,0 +1,49 @@
+package ru.javaops.docjava.schema;
+
+import jakarta.xml.bind.annotation.XmlRegistry;
+
+@XmlRegistry
+public class ObjectFactory {
+
+    /**
+     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: ru.javaops.docjava.schema
+     */
+    public ObjectFactory() {
+    }
+
+    /**
+     * Create an instance of {@link UsersWithMeals }
+     */
+    public UsersWithMeals createUsersWithMeals() {
+        return new UsersWithMeals();
+    }
+
+    /**
+     * Create an instance of {@link UsersWithMeals.Users }
+     */
+    public UsersWithMeals.Users createUsersWithMealsUsers() {
+        return new UsersWithMeals.Users();
+    }
+
+    /**
+     * Create an instance of {@link User }
+     */
+    public User createUser() {
+        return new User();
+    }
+
+    /**
+     * Create an instance of {@link Meals }
+     */
+    public Meals createMeals() {
+        return new Meals();
+    }
+
+    /**
+     * Create an instance of {@link Meal }
+     */
+    public Meal createMeal() {
+        return new Meal();
+    }
+
+}
