[JAVA-9021] Clean up uncommitted artifacts (#11754)
This commit is contained in:
parent
19d7034d42
commit
a7980094d1
|
@ -1,3 +1,5 @@
|
|||
*.docx
|
||||
temp.xls
|
||||
temp.xlsx
|
||||
|
||||
CellStyleTest_output.xlsx
|
|
@ -1,4 +1,6 @@
|
|||
/target/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
||||
.project
|
||||
|
||||
*.log
|
||||
|
|
|
@ -1,14 +1,29 @@
|
|||
package com.baeldung.externalizable;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ExternalizableUnitTest {
|
||||
|
||||
private final static String OUTPUT_FILE = "externalizable.txt";
|
||||
private final static String OUTPUT_FILE_NAME = "externalizable.txt";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
private File outputFile;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
outputFile = tempFolder.newFile(OUTPUT_FILE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException {
|
||||
|
@ -18,7 +33,7 @@ public class ExternalizableUnitTest {
|
|||
c.setCode(374);
|
||||
c.setName("Armenia");
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||
c.writeExternal(objectOutputStream);
|
||||
|
||||
|
@ -26,7 +41,7 @@ public class ExternalizableUnitTest {
|
|||
objectOutputStream.close();
|
||||
fileOutputStream.close();
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE);
|
||||
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||
|
||||
Country c2 = new Country();
|
||||
|
@ -35,8 +50,8 @@ public class ExternalizableUnitTest {
|
|||
objectInputStream.close();
|
||||
fileInputStream.close();
|
||||
|
||||
assertTrue(c2.getCode() == c.getCode());
|
||||
assertTrue(c2.getName().equals(c.getName()));
|
||||
assertEquals(c2.getCode(), c.getCode());
|
||||
assertEquals(c2.getName(), c.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -49,7 +64,7 @@ public class ExternalizableUnitTest {
|
|||
r.setClimate("Mediterranean");
|
||||
r.setPopulation(120.000);
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||
r.writeExternal(objectOutputStream);
|
||||
|
||||
|
@ -57,7 +72,7 @@ public class ExternalizableUnitTest {
|
|||
objectOutputStream.close();
|
||||
fileOutputStream.close();
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE);
|
||||
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||
|
||||
Region r2 = new Region();
|
||||
|
@ -66,6 +81,6 @@ public class ExternalizableUnitTest {
|
|||
objectInputStream.close();
|
||||
fileInputStream.close();
|
||||
|
||||
assertTrue(r2.getPopulation() == null);
|
||||
assertNull(r2.getPopulation());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,54 @@
|
|||
package com.baeldung.serialization;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PersonUnitTest {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
private File outputFile;
|
||||
|
||||
private File outputFile2;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
outputFile = tempFolder.newFile("yourfile.txt");
|
||||
outputFile2 = tempFolder.newFile("yourfile2.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOException, ClassNotFoundException {
|
||||
Person p = new Person();
|
||||
p.setAge(20);
|
||||
p.setName("Joe");
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||
objectOutputStream.writeObject(p);
|
||||
objectOutputStream.flush();
|
||||
objectOutputStream.close();
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream("yofile.txt");
|
||||
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||
Person p2 = (Person) objectInputStream.readObject();
|
||||
objectInputStream.close();
|
||||
|
||||
assertTrue(p2.getAge() == p.getAge());
|
||||
assertTrue(p2.getName().equals(p.getName()));
|
||||
assertEquals(p2.getAge(), p.getAge());
|
||||
assertEquals(p2.getName(), p.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -46,19 +64,19 @@ public class PersonUnitTest {
|
|||
e.setPerson(p);
|
||||
e.setAddress(a);
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile2.txt");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(outputFile2);
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||
objectOutputStream.writeObject(e);
|
||||
objectOutputStream.flush();
|
||||
objectOutputStream.close();
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream("yofile2.txt");
|
||||
FileInputStream fileInputStream = new FileInputStream(outputFile2);
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||
Employee e2 = (Employee) objectInputStream.readObject();
|
||||
objectInputStream.close();
|
||||
|
||||
assertTrue(e2.getPerson().getAge() == e.getPerson().getAge());
|
||||
assertTrue(e2.getAddress().getHouseNumber() == (e.getAddress().getHouseNumber()));
|
||||
assertEquals(e2.getPerson().getAge(), e.getPerson().getAge());
|
||||
assertEquals(e2.getAddress().getHouseNumber(), (e.getAddress().getHouseNumber()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -13,17 +14,32 @@ import java.io.ObjectOutputStream;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.util.MySerializationUtils;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class SerializationUnitTest {
|
||||
|
||||
private final static String OUTPUT_FILE_NAME = "yourfile.txt";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
private File outputFile;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
outputFile = tempFolder.newFile(OUTPUT_FILE_NAME);
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException.class)
|
||||
public void whenSerializing_ThenThrowsError() throws IOException {
|
||||
Address address = new Address();
|
||||
address.setHouseNumber(10);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
|
||||
objectOutputStream.writeObject(address);
|
||||
}
|
||||
|
@ -35,12 +51,12 @@ public class SerializationUnitTest {
|
|||
p.setAge(20);
|
||||
p.setName("Joe");
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
|
||||
objectOutputStream.writeObject(p);
|
||||
}
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream("yofile.txt");
|
||||
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||
try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
|
||||
Person p2 = (Person) objectInputStream.readObject();
|
||||
assertEquals(p2.getAge(), p.getAge());
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the com.baeldung.jaxb.gen package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link UserRequest }
|
||||
*
|
||||
*/
|
||||
public UserRequest createUserRequest() {
|
||||
return new UserRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link UserResponse }
|
||||
*
|
||||
*/
|
||||
public UserResponse createUserResponse() {
|
||||
return new UserResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the com.baeldung.jaxb.gen package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link UserRequest }
|
||||
*
|
||||
*/
|
||||
public UserRequest createUserRequest() {
|
||||
return new UserRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link UserResponse }
|
||||
*
|
||||
*/
|
||||
public UserResponse createUserResponse() {
|
||||
return new UserResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,87 +1,87 @@
|
|||
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for UserRequest complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="UserRequest">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "UserRequest", propOrder = {
|
||||
"id",
|
||||
"name"
|
||||
})
|
||||
@XmlRootElement(name = "userRequest")
|
||||
public class UserRequest
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private final static long serialVersionUID = -1L;
|
||||
protected int id;
|
||||
@XmlElement(required = true)
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* Gets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for UserRequest complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="UserRequest">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "UserRequest", propOrder = {
|
||||
"id",
|
||||
"name"
|
||||
})
|
||||
@XmlRootElement(name = "userRequest")
|
||||
public class UserRequest
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private final static long serialVersionUID = -1L;
|
||||
protected int id;
|
||||
@XmlElement(required = true)
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* Gets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,149 +1,149 @@
|
|||
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.w3._2001.xmlschema.Adapter1;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for UserResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="UserResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="gender" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="created" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "UserResponse", propOrder = {
|
||||
"id",
|
||||
"name",
|
||||
"gender",
|
||||
"created"
|
||||
})
|
||||
@XmlRootElement(name = "userResponse")
|
||||
public class UserResponse
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private final static long serialVersionUID = -1L;
|
||||
protected int id;
|
||||
@XmlElement(required = true)
|
||||
protected String name;
|
||||
@XmlElement(required = true)
|
||||
protected String gender;
|
||||
@XmlElement(required = true, type = String.class)
|
||||
@XmlJavaTypeAdapter(Adapter1 .class)
|
||||
@XmlSchemaType(name = "dateTime")
|
||||
protected Calendar created;
|
||||
|
||||
/**
|
||||
* Gets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the gender property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the gender property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setGender(String value) {
|
||||
this.gender = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the created property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public Calendar getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the created property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setCreated(Calendar value) {
|
||||
this.created = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.w3._2001.xmlschema.Adapter1;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for UserResponse complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="UserResponse">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="gender" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="created" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "UserResponse", propOrder = {
|
||||
"id",
|
||||
"name",
|
||||
"gender",
|
||||
"created"
|
||||
})
|
||||
@XmlRootElement(name = "userResponse")
|
||||
public class UserResponse
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private final static long serialVersionUID = -1L;
|
||||
protected int id;
|
||||
@XmlElement(required = true)
|
||||
protected String name;
|
||||
@XmlElement(required = true)
|
||||
protected String gender;
|
||||
@XmlElement(required = true, type = String.class)
|
||||
@XmlJavaTypeAdapter(Adapter1 .class)
|
||||
@XmlSchemaType(name = "dateTime")
|
||||
protected Calendar created;
|
||||
|
||||
/**
|
||||
* Gets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the id property.
|
||||
*
|
||||
*/
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the gender property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the gender property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setGender(String value) {
|
||||
this.gender = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the created property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public Calendar getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the created property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setCreated(Calendar value) {
|
||||
this.created = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/jaxb/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||
package com.baeldung.jaxb.gen;
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/jaxb/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||
package com.baeldung.jaxb.gen;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
|
||||
package org.w3._2001.xmlschema;
|
||||
|
||||
import java.util.Calendar;
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
public class Adapter1
|
||||
extends XmlAdapter<String, Calendar>
|
||||
{
|
||||
|
||||
|
||||
public Calendar unmarshal(String value) {
|
||||
return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
|
||||
}
|
||||
|
||||
public String marshal(Calendar value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return (javax.xml.bind.DatatypeConverter.printDateTime(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package org.w3._2001.xmlschema;
|
||||
|
||||
import java.util.Calendar;
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
public class Adapter1
|
||||
extends XmlAdapter<String, Calendar>
|
||||
{
|
||||
|
||||
|
||||
public Calendar unmarshal(String value) {
|
||||
return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
|
||||
}
|
||||
|
||||
public String marshal(Calendar value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return (javax.xml.bind.DatatypeConverter.printDateTime(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue