mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-19 21:25:38 +00:00
feat: Using text blocks instead of String literals (#2791)
This commit is contained in:
@@ -44,6 +44,20 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class CombinatorApp {
|
||||
|
||||
private static final String TEXT = """
|
||||
It was many and many a year ago,
|
||||
In a kingdom by the sea,
|
||||
That a maiden there lived whom you may know
|
||||
By the name of ANNABEL LEE;
|
||||
And this maiden she lived with no other thought
|
||||
Than to love and be loved by me.
|
||||
I was a child and she was a child,
|
||||
In this kingdom by the sea;
|
||||
But we loved with a love that was more than love-
|
||||
I and my Annabel Lee;
|
||||
With a love that the winged seraphs of heaven
|
||||
Coveted her and me.""";
|
||||
|
||||
/**
|
||||
* main.
|
||||
* @param args args
|
||||
@@ -69,19 +83,8 @@ public class CombinatorApp {
|
||||
}
|
||||
|
||||
private static String text() {
|
||||
return
|
||||
"It was many and many a year ago,\n"
|
||||
+ "In a kingdom by the sea,\n"
|
||||
+ "That a maiden there lived whom you may know\n"
|
||||
+ "By the name of ANNABEL LEE;\n"
|
||||
+ "And this maiden she lived with no other thought\n"
|
||||
+ "Than to love and be loved by me.\n"
|
||||
+ "I was a child and she was a child,\n"
|
||||
+ "In this kingdom by the sea;\n"
|
||||
+ "But we loved with a love that was more than love-\n"
|
||||
+ "I and my Annabel Lee;\n"
|
||||
+ "With a love that the winged seraphs of heaven\n"
|
||||
+ "Coveted her and me.";
|
||||
|
||||
return TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,10 @@ class FinderTest {
|
||||
|
||||
@Test
|
||||
void contains() {
|
||||
var example = "the first one \nthe second one \n";
|
||||
var example = """
|
||||
the first one
|
||||
the second one\s
|
||||
""";
|
||||
|
||||
var result = Finder.contains("second").find(example);
|
||||
assertEquals(1, result.size());
|
||||
|
||||
@@ -67,18 +67,19 @@ class FindersTest {
|
||||
|
||||
private String text() {
|
||||
return
|
||||
"It was many and many a year ago,\n"
|
||||
+ "In a kingdom by the sea,\n"
|
||||
+ "That a maiden there lived whom you may know\n"
|
||||
+ "By the name of ANNABEL LEE;\n"
|
||||
+ "And this maiden she lived with no other thought\n"
|
||||
+ "Than to love and be loved by me.\n"
|
||||
+ "I was a child and she was a child,\n"
|
||||
+ "In this kingdom by the sea;\n"
|
||||
+ "But we loved with a love that was more than love-\n"
|
||||
+ "I and my Annabel Lee;\n"
|
||||
+ "With a love that the winged seraphs of heaven\n"
|
||||
+ "Coveted her and me.";
|
||||
"""
|
||||
It was many and many a year ago,
|
||||
In a kingdom by the sea,
|
||||
That a maiden there lived whom you may know
|
||||
By the name of ANNABEL LEE;
|
||||
And this maiden she lived with no other thought
|
||||
Than to love and be loved by me.
|
||||
I was a child and she was a child,
|
||||
In this kingdom by the sea;
|
||||
But we loved with a love that was more than love-
|
||||
I and my Annabel Lee;
|
||||
With a love that the winged seraphs of heaven
|
||||
Coveted her and me.""";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user