Merge pull request 'Java 多行字符串' (#45) from persistence-modules into main
Reviewed-on: https://src.ossez.com/cwiki-us-docs/java-tutorials/pulls/45
This commit is contained in:
commit
3b344e5c9f
|
@ -18,6 +18,7 @@
|
|||
<module name="core-java-numbers" />
|
||||
<module name="discourse" />
|
||||
<module name="core-java-strings" />
|
||||
<module name="core-java" />
|
||||
<module name="core-java-11" />
|
||||
<module name="core-java-collections-list-2" />
|
||||
<module name="core-java-collections" />
|
||||
|
|
|
@ -33,6 +33,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/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/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/persistence-modules/activejdbc/src/main/java" charset="UTF-8" />
|
||||
|
|
|
@ -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)
|
||||
- [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)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
- [Java Localization – Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting)
|
||||
- [Java – Generate Random String](https://www.baeldung.com/java-random-string)
|
||||
- [Java String Interview Questions and Answers](https://www.baeldung.com/java-string-interview-questions)
|
||||
- [Java Multi-line String](https://www.baeldung.com/java-multiline-string)
|
||||
- [Java 多行字符串](https://www.ossez.com/t/java/14049)
|
||||
- [Java 中的 String Pool 简介](https://www.ossez.com/t/java-string-pool/14017)
|
||||
- [Java “constant string too long” 编译错误](https://www.ossez.com/t/java-constant-string-too-long/14048)
|
||||
- [Java 对象如何安全的 toString](https://www.ossez.com/t/java-tostring/14000)
|
||||
|
|
|
@ -2,14 +2,13 @@ package com.ossez.multiline;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MultiLineStringUnitTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void whenCompareMultiLineStrings_thenTheyAreAllTheSame() throws IOException {
|
||||
MultiLineString ms = new MultiLineString();
|
||||
|
@ -17,7 +16,13 @@ public class MultiLineStringUnitTest {
|
|||
assertEquals(ms.stringJoin(), ms.stringBuilder());
|
||||
assertEquals(ms.stringBuilder(), ms.guavaJoiner());
|
||||
assertEquals(ms.guavaJoiner(), ms.loadFromFile());
|
||||
assertEquals(ms.loadFromFile(), ms.textBlocks());
|
||||
|
||||
// Due to JDK version, we cannot test TestBlocks
|
||||
// assertEquals(ms.loadFromFile(), ms.textBlocks());
|
||||
}
|
||||
@Test
|
||||
public void newlineInOS() throws IOException {
|
||||
System.out.println(System.lineSeparator());
|
||||
System.out.println(System.getProperty("line.separator"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
*.class
|
||||
|
||||
0.*
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
.resourceCache
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# Files generated by integration tests
|
||||
*.txt
|
||||
backup-pom.xml
|
||||
/bin/
|
||||
/temp
|
||||
|
||||
#IntelliJ specific
|
||||
.idea/
|
||||
*.iml
|
|
@ -0,0 +1,6 @@
|
|||
## Java 核心
|
||||
|
||||
本模块中包含有关 Java 核心新增功能特性的一些文章。
|
||||
|
||||
### 相关文章:
|
||||
- [Java Preview Features](https://www.baeldung.com/java-preview-features)
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java</artifactId>
|
||||
<name>core-java</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>${commons-collections4.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>core-java-8</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package com.ossez.features;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
|
||||
public class Template {
|
||||
|
||||
private static final Clock clock = Clock.fixed(Instant.parse("2016-10-09T15:10:30.00Z"), ZoneId.of("UTC"));
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="TRACE">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,42 @@
|
|||
package com.ossez.features.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.ChronoField;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CurrentDateTimeUnitTest {
|
||||
|
||||
private static final Clock clock = Clock.fixed(Instant.parse("2016-10-09T15:10:30.00Z"), ZoneId.of("UTC"));
|
||||
|
||||
@Test
|
||||
public void shouldReturnCurrentDate() {
|
||||
final LocalDate now = LocalDate.now(clock);
|
||||
|
||||
assertEquals(9, now.get(ChronoField.DAY_OF_MONTH));
|
||||
assertEquals(10, now.get(ChronoField.MONTH_OF_YEAR));
|
||||
assertEquals(2016, now.get(ChronoField.YEAR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnCurrentTime() {
|
||||
final LocalTime now = LocalTime.now(clock);
|
||||
|
||||
assertEquals(15, now.get(ChronoField.HOUR_OF_DAY));
|
||||
assertEquals(10, now.get(ChronoField.MINUTE_OF_HOUR));
|
||||
assertEquals(30, now.get(ChronoField.SECOND_OF_MINUTE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnCurrentTimestamp() {
|
||||
final Instant now = Instant.now(clock);
|
||||
|
||||
assertEquals(clock.instant().getEpochSecond(), now.getEpochSecond());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
*.class
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
|
@ -15,6 +15,7 @@
|
|||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>core-java</module>
|
||||
<module>core-java-8</module>
|
||||
<module>core-java-8-2</module>
|
||||
<module>core-java-11</module>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package com.baeldung.spring.data.persistence.repository;
|
||||
|
||||
public interface IFooService {
|
||||
Foo create(Foo foo);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.spring.data.persistence.repository;
|
||||
package com.baeldung.spring.data.persistence.saveperformance.repository;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.spring.data.persistence.repository;
|
||||
package com.baeldung.spring.data.persistence.saveperformance.repository;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.spring.data.persistence.repository;
|
||||
package com.baeldung.spring.data.persistence.saveperformance.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.spring.data.persistence.saveperformance.repository;
|
||||
|
||||
public interface IFooService {
|
||||
Foo create(Foo foo);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.spring.data.persistence.repository;
|
||||
package com.baeldung.spring.data.persistence.saveperformance.repository;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -1,5 +1,8 @@
|
|||
package com.baeldung.spring.data.persistence.repository;
|
||||
|
||||
import com.baeldung.spring.data.persistence.saveperformance.repository.Foo;
|
||||
import com.baeldung.spring.data.persistence.saveperformance.repository.IFooService;
|
||||
import com.baeldung.spring.data.persistence.saveperformance.repository.PersistenceConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
Loading…
Reference in New Issue