BAEL-3597 Cactoos (#8512)
* BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos
This commit is contained in:
committed by
maibin
parent
74246a69ec
commit
7a23abe4ff
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.cactoos;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.cactoos.collection.Filtered;
|
||||
import org.cactoos.iterable.IterableOf;
|
||||
import org.cactoos.list.ListOf;
|
||||
import org.cactoos.scalar.And;
|
||||
import org.cactoos.text.FormattedText;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CactoosCollectionUtils {
|
||||
|
||||
final Logger LOGGER = LoggerFactory.getLogger(CactoosCollectionUtils.class);
|
||||
|
||||
public void iterateCollection(List<String> strings) throws Exception {
|
||||
new And((String input) -> LOGGER.info(new FormattedText("%s\n", input).asString()), strings).value();
|
||||
}
|
||||
|
||||
public Collection<String> getFilteredList(List<String> strings) {
|
||||
Collection<String> filteredStrings = new ListOf<>(
|
||||
new Filtered<>(string -> string.length() == 5, new IterableOf<>(strings)));
|
||||
return filteredStrings;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.baeldung.cactoos;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.cactoos.text.FormattedText;
|
||||
import org.cactoos.text.IsBlank;
|
||||
import org.cactoos.text.Lowered;
|
||||
import org.cactoos.text.TextOf;
|
||||
import org.cactoos.text.Upper;
|
||||
|
||||
public class CactoosStringUtils {
|
||||
|
||||
public String createString() throws IOException {
|
||||
String testString = new TextOf("Test String").asString();
|
||||
return testString;
|
||||
}
|
||||
|
||||
public String createdFormattedString(String stringToFormat) throws IOException {
|
||||
String formattedString = new FormattedText("Hello %s", stringToFormat).asString();
|
||||
return formattedString;
|
||||
}
|
||||
|
||||
public String toLowerCase(String testString) throws IOException {
|
||||
String lowerCaseString = new Lowered(new TextOf(testString)).asString();
|
||||
return lowerCaseString;
|
||||
}
|
||||
|
||||
public String toUpperCase(String testString) throws Exception {
|
||||
String upperCaseString = new Upper(new TextOf(testString)).asString();
|
||||
return upperCaseString;
|
||||
}
|
||||
|
||||
public boolean isBlank(String testString) throws Exception {
|
||||
return new IsBlank(new TextOf(testString)) != null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user