Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27db0d5540 | ||
|
|
edcd08e1b2 | ||
|
|
038ce5b547 | ||
|
|
b9d1b0257c | ||
|
|
ddbb638242 | ||
|
|
bf2335eda1 | ||
|
|
1b3b30cae3 | ||
|
|
4711c3a393 | ||
|
|
05d80c840d | ||
|
|
77c51720e9 | ||
|
|
dc99d9404d | ||
|
|
2b1d680b2c | ||
|
|
3b344e5c9f | ||
|
|
f2c3c2bf0f | ||
|
|
b90cdd3306 | ||
|
|
c816787e06 | ||
|
|
e8f74069ff | ||
|
|
ae29615530 | ||
|
|
cd46aea7ac |
Generated
+9
-1
@@ -9,6 +9,7 @@
|
|||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="codebank" />
|
<module name="codebank" />
|
||||||
<module name="core-java-collections-list" />
|
<module name="core-java-collections-list" />
|
||||||
|
<module name="spring-data-jpa-repo-2" />
|
||||||
<module name="core-java-streams" />
|
<module name="core-java-streams" />
|
||||||
<module name="assertion-libraries" />
|
<module name="assertion-libraries" />
|
||||||
<module name="core-java-io" />
|
<module name="core-java-io" />
|
||||||
@@ -16,8 +17,9 @@
|
|||||||
<module name="core-java-8-2" />
|
<module name="core-java-8-2" />
|
||||||
<module name="core-java-numbers" />
|
<module name="core-java-numbers" />
|
||||||
<module name="discourse" />
|
<module name="discourse" />
|
||||||
<module name="core-java-11-2" />
|
<module name="spring-data-redis" />
|
||||||
<module name="core-java-strings" />
|
<module name="core-java-strings" />
|
||||||
|
<module name="core-java" />
|
||||||
<module name="core-java-11" />
|
<module name="core-java-11" />
|
||||||
<module name="core-java-collections-list-2" />
|
<module name="core-java-collections-list-2" />
|
||||||
<module name="core-java-collections" />
|
<module name="core-java-collections" />
|
||||||
@@ -27,8 +29,14 @@
|
|||||||
<module name="junit-5-basics" />
|
<module name="junit-5-basics" />
|
||||||
<module name="core-java-collections-3" />
|
<module name="core-java-collections-3" />
|
||||||
<module name="core-java-collections-2" />
|
<module name="core-java-collections-2" />
|
||||||
|
<module name="activejdbc" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="core-java-11-2" target="11" />
|
||||||
|
<module name="hibernate-annotations" target="1.5" />
|
||||||
|
<module name="hibernate5" target="11" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
<component name="JavacSettings">
|
<component name="JavacSettings">
|
||||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
|||||||
Generated
+12
@@ -33,8 +33,20 @@
|
|||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-streams/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-streams/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-strings/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-strings/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-strings/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-strings/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/activejdbc/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/activejdbc/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/hibernate5/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/hibernate5/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/spring-data-jpa-repo-2/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/spring-data-jpa-repo-2/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/spring-data-redis/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/spring-data-redis/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/persistence-modules/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/testing-modules/assertion-libraries/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/testing-modules/assertion-libraries/src/main/java" charset="UTF-8" />
|
||||||
|
|||||||
Generated
+20
@@ -1,11 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="ossez-repo-snapshots" />
|
||||||
|
<option name="name" value="OSSEZ Private Snapshots" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-snapshots/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="geodb-repo" />
|
||||||
|
<option name="name" value="GeoDB repository" />
|
||||||
|
<option name="url" value="http://repo.boundlessgeo.com/main/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="ossez-repo-releases" />
|
||||||
|
<option name="name" value="OSSEZ Private Releases" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-releases/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Maven Central repository" />
|
<option name="name" value="Maven Central repository" />
|
||||||
|
|||||||
Generated
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JpaBuddyIdeaProjectConfig">
|
||||||
|
<option name="defaultUnitInitialized" value="true" />
|
||||||
|
<option name="renamerInitialized" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCSFixerOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<br>提供 CWIKI.US 项目中使用的代码
|
<br>提供 CWIKI.US 项目中使用的代码
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
所有的 Java 代码使用的是 JDK 11。
|
Java 代码使用的是 JDK 11。
|
||||||
|
|
||||||
你可以通过单击下面连接后访问我们网站,并且访问我们提供的最新有关 Java 的开发资料。
|
你可以通过单击下面连接后访问我们网站,并且访问我们提供的最新有关 Java 的开发资料。
|
||||||
|
|
||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
# 公众平台
|
# 公众平台
|
||||||
|
|
||||||
我们建议您通过社区论坛来和我们进行沟通,请关注我们公众平台上的账号
|
我们建议您通过社区论坛来和我们进行沟通,请关注我们公众平台上的账号。
|
||||||
|
|
||||||
|
扫描 QR 关注我们的微信公众号和头条号。
|
||||||
|
|
||||||
## 微信公众号
|
## 微信公众号
|
||||||
|
|
||||||
@@ -33,10 +35,11 @@
|
|||||||
|
|
||||||
## 头条号
|
## 头条号
|
||||||
|
|
||||||
我们也在头条号上创建了我们的公众号,请扫描下面的 QR 关注我们的头条号。
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## 知乎
|
||||||
|
请关注我们的知乎:https://www.zhihu.com/people/huyuchengus
|
||||||
|
|
||||||
## 快速导航
|
## 快速导航
|
||||||
|
|
||||||
在下面的表格中,我们列出了一些比较有用的 CWIKIUS 相关软件开发使用教程的导航,欢迎访问下面的链接获得更多的内容和参与讨论
|
在下面的表格中,我们列出了一些比较有用的 CWIKIUS 相关软件开发使用教程的导航,欢迎访问下面的链接获得更多的内容和参与讨论
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
## 相关文章
|
## 相关文章
|
||||||
|
|
||||||
|
- [J2EE,Java EE,Jakarta EE 命名之间的恩恩怨怨](https://www.ossez.com/t/j2ee-java-ee-jakarta-ee/14382)
|
||||||
- [Understanding the NumberFormatException in Java](https://www.baeldung.com/java-number-format-exception)
|
- [Understanding the NumberFormatException in Java](https://www.baeldung.com/java-number-format-exception)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
本模块中包含有关 Java 11 核心新增功能的的一些文章
|
本模块中包含有关 Java 11 核心新增功能的的一些文章
|
||||||
|
|
||||||
### 相关文章
|
### 相关文章
|
||||||
- [Java 8 开始新增的 Optional 类](https://www.ossez.com/t/java-8-optional/13964)
|
|
||||||
- [Guide to Java Reflection](http://www.baeldung.com/java-reflection)
|
- [Guide to Java Reflection](http://www.baeldung.com/java-reflection)
|
||||||
- [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors)
|
- [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors)
|
||||||
- [New Features in Java 11](https://www.baeldung.com/java-11-new-features)
|
- [New Features in Java 11](https://www.baeldung.com/java-11-new-features)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>${guava.version}</version>
|
<version>${version.guava}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mock-server</groupId>
|
<groupId>org.mock-server</groupId>
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ This module contains articles about Java 11 core features
|
|||||||
- [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference)
|
- [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference)
|
||||||
- [Benchmark JDK Collections vs Eclipse Collections](https://www.baeldung.com/jdk-collections-vs-eclipse-collections)
|
- [Benchmark JDK Collections vs Eclipse Collections](https://www.baeldung.com/jdk-collections-vs-eclipse-collections)
|
||||||
- [Pre-compile Regex Patterns Into Pattern Objects](https://www.baeldung.com/java-regex-pre-compile)
|
- [Pre-compile Regex Patterns Into Pattern Objects](https://www.baeldung.com/java-regex-pre-compile)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>${guava.version}</version>
|
<version>${version.guava}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
本模块中包含有关 Java 8 核心新增功能特性的一些文章。
|
本模块中包含有关 Java 8 核心新增功能特性的一些文章。
|
||||||
|
|
||||||
### 相关文章
|
### 相关文章
|
||||||
|
|
||||||
- [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments)
|
- [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments)
|
||||||
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)
|
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)
|
||||||
- [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface)
|
- [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface)
|
||||||
- [Interface With Default Methods vs Abstract Class](https://www.baeldung.com/java-interface-default-method-vs-abstract-class)
|
- [Interface With Default Methods vs Abstract Class](https://www.baeldung.com/java-interface-default-method-vs-abstract-class)
|
||||||
- [Convert Between Byte Array and UUID in Java](https://www.baeldung.com/java-byte-array-to-uuid)
|
- [Convert Between Byte Array and UUID in Java](https://www.baeldung.com/java-byte-array-to-uuid)
|
||||||
- [Create a Simple “Rock-Paper-Scissors” Game in Java](https://www.baeldung.com/java-rock-paper-scissors)
|
- [Create a Simple “Rock-Paper-Scissors” Game in Java](https://www.baeldung.com/java-rock-paper-scissors)
|
||||||
|
- [Java 8 开始新增的 Optional 类](https://www.ossez.com/t/java-8-optional/13964)
|
||||||
- [[<-- Java 8 核心(第 1 部分)]](/core-java-modules/core-java-8)
|
- [[<-- Java 8 核心(第 1 部分)]](/core-java-modules/core-java-8)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>${log4j.version}</version>
|
<version>${version.log4j}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- test scoped -->
|
<!-- test scoped -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -71,12 +71,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>${log4j.version}</version>
|
<version>${version.log4j}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>log4j-over-slf4j</artifactId>
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
<version>${slf4j.version}</version>
|
<version>${version.slf4j}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
|||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.ossez.java9.compactstring;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
public class CompactStringDemo {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
List strings = IntStream.rangeClosed(1, 10_000_000).mapToObj(Integer::toString).collect(toList());
|
|
||||||
long totalTime = System.currentTimeMillis() - startTime;
|
|
||||||
System.out.println("Generated " + strings.size() + " strings in " + totalTime + " ms.");
|
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
|
||||||
String appended = (String) strings.stream().limit(100_000).reduce("", (left, right) -> left.toString() + right.toString());
|
|
||||||
totalTime = System.currentTimeMillis() - startTime;
|
|
||||||
System.out.println("Created string of length " + appended.length() + " in " + totalTime + " ms.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.ossez.localization;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class App {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs all available formatter
|
|
||||||
* @throws ParseException
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
List<Locale> locales = Arrays.asList(new Locale[] { Locale.UK, Locale.ITALY, Locale.FRANCE, Locale.forLanguageTag("pl-PL") });
|
|
||||||
Localization.run(locales);
|
|
||||||
JavaSEFormat.run(locales);
|
|
||||||
ICUFormat.run(locales);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
package com.ossez.localization;
|
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
public class ICUFormat {
|
|
||||||
|
|
||||||
public static String getLabel(Locale locale, Object[] data) {
|
|
||||||
ResourceBundle bundle = ResourceBundle.getBundle("formats", locale);
|
|
||||||
String format = bundle.getString("label-icu");
|
|
||||||
MessageFormat formatter = new MessageFormat(format, locale);
|
|
||||||
return formatter.format(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void run(List<Locale> locales) {
|
|
||||||
System.out.println("ICU formatter");
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 0 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 1 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 2 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Alice", "female", 3 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 0 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 1 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 2 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { "Bob", "male", 3 })));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
package com.ossez.localization;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
public class JavaSEFormat {
|
|
||||||
|
|
||||||
public static String getLabel(Locale locale, Object[] data) {
|
|
||||||
ResourceBundle bundle = ResourceBundle.getBundle("formats", locale);
|
|
||||||
final String pattern = bundle.getString("label");
|
|
||||||
final MessageFormat formatter = new MessageFormat(pattern, locale);
|
|
||||||
return formatter.format(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void run(List<Locale> locales) {
|
|
||||||
System.out.println("Java formatter");
|
|
||||||
final Date date = new Date(System.currentTimeMillis());
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { date, "Alice", 0 })));
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale, new Object[] { date, "Alice", 2 })));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
package com.ossez.localization;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
public class Localization {
|
|
||||||
|
|
||||||
public static String getLabel(Locale locale) {
|
|
||||||
final ResourceBundle bundle = ResourceBundle.getBundle("messages", locale);
|
|
||||||
return bundle.getString("label");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void run(List<Locale> locales) {
|
|
||||||
locales.forEach(locale -> System.out.println(getLabel(locale)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-198
@@ -1,198 +0,0 @@
|
|||||||
package com.ossez.stringperformance;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.openjdk.jmh.annotations.*;
|
|
||||||
import org.openjdk.jmh.runner.Runner;
|
|
||||||
import org.openjdk.jmh.runner.options.Options;
|
|
||||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@BenchmarkMode(Mode.SingleShotTime)
|
|
||||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
|
||||||
@Measurement(batchSize = 100000, iterations = 10)
|
|
||||||
@Warmup(batchSize = 100000, iterations = 10)
|
|
||||||
@State(Scope.Thread)
|
|
||||||
public class StringPerformance {
|
|
||||||
|
|
||||||
protected String baeldung = "baeldung";
|
|
||||||
protected String longString = "Hello baeldung, I am a bit longer than other Strings";
|
|
||||||
protected String formatString = "hello %s, nice to meet you";
|
|
||||||
protected String formatDigit = "%d";
|
|
||||||
protected String emptyString = " ";
|
|
||||||
protected String result = "";
|
|
||||||
|
|
||||||
protected int sampleNumber = 100;
|
|
||||||
|
|
||||||
protected Pattern spacePattern = Pattern.compile(emptyString);
|
|
||||||
protected Pattern longPattern = Pattern.compile(longString);
|
|
||||||
protected List<String> stringSplit = new ArrayList<>();
|
|
||||||
protected List<String> stringTokenizer = new ArrayList<>();
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringDynamicConcat() {
|
|
||||||
result += baeldung;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public StringBuilder benchmarkStringBuilder() {
|
|
||||||
StringBuilder stringBuilder = new StringBuilder(result);
|
|
||||||
stringBuilder.append(baeldung);
|
|
||||||
return stringBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public StringBuffer benchmarkStringBuffer() {
|
|
||||||
StringBuffer stringBuffer = new StringBuffer(result);
|
|
||||||
stringBuffer.append(baeldung);
|
|
||||||
return stringBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringConstructor() {
|
|
||||||
String result = new String("baeldung");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringLiteral() {
|
|
||||||
String result = "baeldung";
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringFormat_s() {
|
|
||||||
return String.format(formatString, baeldung);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringConcat() {
|
|
||||||
result = result.concat(baeldung);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringIntern() {
|
|
||||||
return baeldung.intern();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringReplace() {
|
|
||||||
return longString.replace("average", " average !!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringUtilsReplace() {
|
|
||||||
return StringUtils.replace(longString, "average", " average !!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public List<String> benchmarkGuavaSplitter() {
|
|
||||||
return Splitter.on(" ").trimResults()
|
|
||||||
.omitEmptyStrings()
|
|
||||||
.splitToList(longString);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String [] benchmarkStringSplit() {
|
|
||||||
return longString.split(emptyString);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String [] benchmarkStringSplitPattern() {
|
|
||||||
return spacePattern.split(longString, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public List benchmarkStringTokenizer() {
|
|
||||||
StringTokenizer st = new StringTokenizer(longString);
|
|
||||||
while (st.hasMoreTokens()) {
|
|
||||||
stringTokenizer.add(st.nextToken());
|
|
||||||
}
|
|
||||||
return stringTokenizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public List benchmarkStringIndexOf() {
|
|
||||||
int pos = 0, end;
|
|
||||||
while ((end = longString.indexOf(' ', pos)) >= 0) {
|
|
||||||
stringSplit.add(longString.substring(pos, end));
|
|
||||||
pos = end + 1;
|
|
||||||
}
|
|
||||||
//Add last token of string
|
|
||||||
stringSplit.add(longString.substring(pos));
|
|
||||||
return stringSplit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkIntegerToString() {
|
|
||||||
return Integer.toString(sampleNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringValueOf() {
|
|
||||||
return String.valueOf(sampleNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringConvertPlus() {
|
|
||||||
return sampleNumber + "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public String benchmarkStringFormat_d() {
|
|
||||||
return String.format(formatDigit, sampleNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public boolean benchmarkStringEquals() {
|
|
||||||
return longString.equals(baeldung);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public boolean benchmarkStringEqualsIgnoreCase() {
|
|
||||||
return longString.equalsIgnoreCase(baeldung);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public boolean benchmarkStringMatches() {
|
|
||||||
return longString.matches(baeldung);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public boolean benchmarkPrecompiledMatches() {
|
|
||||||
return longPattern.matcher(baeldung).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public int benchmarkStringCompareTo() {
|
|
||||||
return longString.compareTo(baeldung);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public boolean benchmarkStringIsEmpty() {
|
|
||||||
return longString.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public boolean benchmarkStringLengthZero() {
|
|
||||||
return longString.length() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
Options options = new OptionsBuilder()
|
|
||||||
.include(StringPerformance.class.getSimpleName()).threads(1)
|
|
||||||
.forks(1).shouldFailOnError(true)
|
|
||||||
.shouldDoGC(true)
|
|
||||||
.jvmArgs("-server").build();
|
|
||||||
new Runner(options).run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
|
|||||||
label=On {0, date, short} {1} has sent you {2, choice, 0#no messages|1#a message|2#two messages|2<{2,number,integer} messages}.
|
|
||||||
label-icu={0} has sent you {2, plural, =0 {no messages} =1 {a message} other {{2, number, integer} messages}}.
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
label={0, date, short}, {1}{2, choice, 0# ne|0<} vous a envoy\u00e9 {2, choice, 0#aucun message|1#un message|2#deux messages|2<{2,number,integer} messages}.
|
|
||||||
label-icu={0} {2, plural, =0 {ne } other {}}vous a envoy\u00e9 {2, plural, =0 {aucun message} =1 {un message} other {{2, number, integer} messages}}.
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
label={0, date, short} {1} ti ha inviato {2, choice, 0#nessun messagio|1#un messaggio|2#due messaggi|2<{2, number, integer} messaggi}.
|
|
||||||
label-icu={0} {2, plural, =0 {non } other {}}ti ha inviato {2, plural, =0 {nessun messaggio} =1 {un messaggio} other {{2, number, integer} messaggi}}.
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
label=W {0, date, short} {1}{2, choice, 0# nie|0<} wys\u0142a\u0142a ci {2, choice, 0#\u017Cadnych wiadomo\u015Bci|1#wiadomo\u015B\u0107|2#dwie wiadomo\u015Bci|2<{2, number, integer} wiadomo\u015Bci}.
|
|
||||||
label-icu={0} {2, plural, =0 {nie } other {}}{1, select, male {wys\u0142a\u0142} female {wys\u0142a\u0142a} other {wys\u0142a\u0142o}} ci {2, plural, =0 {\u017Cadnej wiadomo\u015Bci} =1 {wiadomo\u015B\u0107} other {{2, number, integer} wiadomo\u015Bci}}.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
label=Alice has sent you a message.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
label=Alice vous a envoy\u00e9 un message.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
label=Alice ti ha inviato un messaggio.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
label=Alice wys\u0142a\u0142a ci wiadomo\u015B\u0107.
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Get busy living
|
|
||||||
or
|
|
||||||
get busy dying.
|
|
||||||
--Stephen King
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user