本文整理汇总了Java中org.cactoos.iterable.IterableOf类的典型用法代码示例。如果您正苦于以下问题:Java IterableOf类的具体用法?Java IterableOf怎么用?Java IterableOf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IterableOf类属于org.cactoos.iterable包,在下文中一共展示了IterableOf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Report
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
/**
* Ctor.
* @param xml Skeleton
* @param name Name of the metric
* @param args Params for XSL
* @param mean Mean
* @param sigma Sigma
* @checkstyle ParameterNumberCheck (10 lines)
*/
Report(final XML xml, final String name,
final Map<String, Object> args,
final double mean, final double sigma) {
this.skeleton = xml;
this.metric = name;
this.params = args;
this.post = new IterableOf<>(
new XSLDocument(
Report.class.getResourceAsStream("xsl/metric-post-colors.xsl")
).with("low", mean - sigma).with("high", mean + sigma),
new XSLDocument(
Report.class.getResourceAsStream("xsl/metric-post-range.xsl")
),
new XSLDocument(
Report.class.getResourceAsStream("xsl/metric-post-bars.xsl")
)
);
}
示例2: skipIterator
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void skipIterator() throws Exception {
MatcherAssert.assertThat(
"Can't skip elements in iterator",
() -> new Skipped<>(
2,
new IterableOf<>(
"one", "two", "three", "four"
).iterator()
),
Matchers.contains(
"three",
"four"
)
);
}
示例3: extendsExistingMapWithFunc
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void extendsExistingMapWithFunc() throws Exception {
MatcherAssert.assertThat(
"Can't transform and decorate a list of entries",
new StickyMap<String, String>(
color -> new MapEntry<>(
color, color.toUpperCase(Locale.ENGLISH)
),
new StickyMap<String, String>(
new MapEntry<>("black", "BLACK"),
new MapEntry<>("white", "WHITE")
),
new IterableOf<>("yellow", "red", "blue")
),
Matchers.hasValue(Matchers.equalTo("BLUE"))
);
}
示例4: extendsExistingMapWithTwoFuncs
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void extendsExistingMapWithTwoFuncs() throws Exception {
MatcherAssert.assertThat(
"Can't transform and decorate a list of entries with two funcs",
new StickyMap<String, String>(
color -> String.format("[%s]", color),
String::toUpperCase,
new StickyMap<String, String>(
new MapEntry<>("black!", "Black!"),
new MapEntry<>("white!", "White!")
),
new IterableOf<>("yellow!", "red!", "blue!")
),
Matchers.hasValue(Matchers.equalTo("BLUE!"))
);
}
示例5: makesListFromMappedIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void makesListFromMappedIterable() throws Exception {
final List<Integer> list = new SolidList<>(
new Mapped<>(
i -> i + 1,
new IterableOf<>(1, -1, 0, 1)
)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list",
list, Matchers.iterableWithSize(4)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list, again",
list, Matchers.iterableWithSize(4)
);
}
示例6: makesListFromMappedIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void makesListFromMappedIterable() throws Exception {
final List<Integer> list = new ListOf<>(
new Mapped<>(
i -> i + 1,
new IterableOf<>(1, -1, 0, 1)
)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list",
list, Matchers.iterableWithSize(4)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list, again",
list, Matchers.iterableWithSize(4)
);
}
示例7: makesListFromMappedIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void makesListFromMappedIterable() throws Exception {
final List<Integer> list = new StickyList<>(
new Mapped<>(
i -> i + 1,
new IterableOf<>(1, -1, 0, 1)
)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list",
list, Matchers.iterableWithSize(4)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list, again",
list, Matchers.iterableWithSize(4)
);
}
示例8: withoutIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void withoutIterable() throws Exception {
MatcherAssert.assertThat(
new LengthOf(
new Filtered<>(
input -> input.endsWith("12"), new Mapped<>(
new ChainedFunc<String, String, String>(
input -> input.concat("1"),
input -> input.concat("2")
), new IterableOf<>("public", "final", "class")
)
)
).intValue(),
Matchers.equalTo(3)
);
}
示例9: withIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void withIterable() throws Exception {
MatcherAssert.assertThat(
new LengthOf(
new Filtered<>(
input -> !input.startsWith("st"), new Mapped<>(
new ChainedFunc<>(
input -> input.concat("1"),
new IterableOf<Func<String, String>>(
input -> input.concat("2"),
input -> input.replaceAll("a", "b")
),
String::trim
), new IterableOf<>("private", "static", "String")
)
)
).intValue(),
Matchers.equalTo(2)
);
}
示例10: makesListFromMappedIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void makesListFromMappedIterable() throws Exception {
final Collection<Integer> list = new SolidCollection<>(
new org.cactoos.list.Mapped<>(
i -> i + 1,
new IterableOf<>(1, -1, 0, 1)
)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list",
list, Matchers.iterableWithSize(4)
);
MatcherAssert.assertThat(
"Can't turn a mapped iterable into a list, again",
list, Matchers.iterableWithSize(4)
);
}
示例11: iteratesList
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void iteratesList() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list with a procedure",
new And(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true),
new IterableOf<>("hello", "world")
)
),
new ScalarHasValue<>(
Matchers.allOf(
Matchers.equalTo(true),
new MatcherOf<>(
value -> list.size() == 2
)
)
)
);
}
示例12: iteratorThrowsNoSuchElement
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
/**
* Iterator throws {@link NoSuchElementException}.
*
* @throws Exception If fails
*/
@Test(expected = NoSuchElementException.class)
public void iteratorThrowsNoSuchElement() throws Exception {
final String first = "first";
final Iterator<Text> iterator = new ItrtTextOfField(
new IterableOf<Field>(
() -> first
).iterator()
);
MatcherAssert.assertThat(
iterator.next(),
new TextHasString(
first
)
);
iterator.next();
}
示例13: iteratesList
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
public void iteratesList() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list with a procedure",
new AndInThreads(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true),
new IterableOf<>("hello", "world")
)
),
new ScalarHasValue<>(
Matchers.allOf(
Matchers.equalTo(true),
new MatcherOf<>(
value -> list.size() == 2
)
)
)
);
}
示例14: checkValues
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
/**
* Iterator has correct values.
* @throws Exception If fails
*/
@Test
@SuppressWarnings("unchecked")
public void checkValues() throws Exception {
final String first = "first";
final String second = "second";
MatcherAssert.assertThat(
"Iterator sort to texts doesn't has correct values.",
() -> new ItrtTextOfField(
new IterableOf<Field>(
() -> first,
() -> second
).iterator()
),
Matchers.contains(
new TextHasString(
first
),
new TextHasString(
second
)
)
);
}
示例15: sortsIterable
import org.cactoos.iterable.IterableOf; //导入依赖的package包/类
@Test
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void sortsIterable() throws Exception {
MatcherAssert.assertThat(
"Can't sort elements in iterator",
() -> new Sorted<>(
new IterableOf<>(
"one", "two", "three", "four"
).iterator()
),
Matchers.contains(
"four", "one", "three", "two"
)
);
}