Skip to content

Commit

Permalink
Merge pull request #20 from lunasaw/dev_2.5.3
Browse files Browse the repository at this point in the history
2.5.3升级部分依赖
  • Loading branch information
lunasaw authored Dec 14, 2023
2 parents a2337fa + 8d96198 commit 1e30295
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 19 deletions.
25 changes: 12 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.github.lunasaw</groupId>
<artifactId>luna-common</artifactId>
<name>luna-common</name>
<version>2.5.2</version>
<version>2.5.3</version>
<description>common is project which contains common utils</description>
<url>https://github.com/lunasaw/luna-common</url>

Expand All @@ -20,18 +20,17 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!--dependencies-->
<commons-collections4.version>4.4</commons-collections4.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-codec.version>1.15</commons-codec.version>
<commons-io.version>2.11.0</commons-io.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<commons-codec.version>1.16.0</commons-codec.version>
<commons-io.version>2.15.1</commons-io.version>
<httpclient-5.version>5.2.1</httpclient-5.version>
<guava.version>31.1-jre</guava.version>
<joda-time.version>2.10.6</joda-time.version>
<guava.version>32.1.3-jre</guava.version>
<fast-json.version>2.0.26</fast-json.version>
<oshi.version>6.1.3</oshi.version>
<oshi.version>6.4.9</oshi.version>
<junit.version>4.13.2</junit.version>
<lombok.version>1.18.26</lombok.version>
<validation-api.version>2.0.1.Final</validation-api.version>
<slf4j-simple.version>1.7.36</slf4j-simple.version>
<lombok.version>1.18.30</lombok.version>
<validation-api.version>3.0.2</validation-api.version>
<slf4j-simple.version>2.0.9</slf4j-simple.version>
</properties>
<developers>
<developer>
Expand Down Expand Up @@ -108,8 +107,8 @@
<version>${fast-json.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -273,4 +272,4 @@
</build>
</profile>
</profiles>
</project>
</project>
10 changes: 4 additions & 6 deletions src/main/java/com/luna/common/check/ValidDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

import com.luna.common.exception.BaseException;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;

/**
* @author luna
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/com/luna/common/xml/XmlBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.luna.common.xml;

import java.io.StringReader;
import java.io.StringWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;

/**
* @author luna
* @date 2023/10/12
*/
@Getter
@Setter
@XmlAccessorType(XmlAccessType.NONE)
public class XmlBean {

/**
* 字符集, 支持 UTF-8 与 GB2312
*/
private String charset = "UTF-8";

@SneakyThrows
@Override
public String toString() {
JAXBContext jaxbContext = JAXBContext.newInstance(this.getClass());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, charset);

StringWriter writer = new StringWriter();
marshaller.marshal(this, writer);
return writer.toString();
}

@SneakyThrows
public static <T> Object parseObj(String xmlStr, Class<T> clazz) {
JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
return unmarshaller.unmarshal(new StringReader(xmlStr));
}
}

0 comments on commit 1e30295

Please sign in to comment.