本文整理汇总了Java中org.cactoos.iterable.Mapped类的典型用法代码示例。如果您正苦于以下问题:Java Mapped类的具体用法?Java Mapped怎么用?Java Mapped使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mapped类属于org.cactoos.iterable包,在下文中一共展示了Mapped类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withoutIterable
import org.cactoos.iterable.Mapped; //导入依赖的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)
);
}
示例2: withIterable
import org.cactoos.iterable.Mapped; //导入依赖的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)
);
}
示例3: iteratesList
import org.cactoos.iterable.Mapped; //导入依赖的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
)
)
)
);
}
示例4: iteratesEmptyList
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Test
public void iteratesEmptyList() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list",
new AndInThreads(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true), Collections.emptyList()
)
),
new ScalarHasValue<>(
Matchers.allOf(
Matchers.equalTo(true),
new MatcherOf<>(
value -> {
return list.isEmpty();
}
)
)
)
);
}
示例5: iteratesList
import org.cactoos.iterable.Mapped; //导入依赖的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
)
)
)
);
}
示例6: iteratesEmptyList
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Test
public void iteratesEmptyList() {
final List<String> list = new LinkedList<>();
MatcherAssert.assertThat(
"Can't iterate a list",
new And(
new Mapped<String, Scalar<Boolean>>(
new FuncOf<>(list::add, () -> true), Collections.emptyList()
)
),
new ScalarHasValue<>(
Matchers.allOf(
Matchers.equalTo(true),
new MatcherOf<>(
value -> {
return list.isEmpty();
}
)
)
)
);
}
示例7: expired
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Override
public Iterable<Take> expired() {
return new Mapped<>(
this.table()
.frame()
.through(
new QueryValve()
.withIndexName("expired")
.withConsistentRead(false)
.withSelect(Select.ALL_ATTRIBUTES)
)
.where("success", Conditions.equalTo(Boolean.toString(false)))
.where(
"when",
new Condition()
.withComparisonOperator(ComparisonOperator.LT)
.withAttributeValueList(
new AttributeValue().withN(
Long.toString(System.currentTimeMillis())
)
)
),
item -> new DyTake(item, this.delay)
);
}
示例8: scripts
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Override
public Iterable<Iterable<Directive>> scripts() {
return new Mapped<Item, Iterable<Directive>>(
item -> new Directives()
.add("script")
.add("name").set(item.get("name").getS()).up()
.add("bash").set(item.get("bash").getS()).up()
.add("paid").set(item.get("paid").getN()).up()
.add("used").set(item.get("used").getN()).up()
.add("hour").set(item.get("hour").getN()).up()
.add("day").set(item.get("day").getN()).up()
.add("week").set(item.get("week").getN()).up()
.up(),
this.region.table("scripts")
.frame()
.through(
new QueryValve()
// @checkstyle MagicNumber (1 line)
.withLimit(10)
.withSelect(Select.ALL_ATTRIBUTES)
)
.where("login", this.login)
);
}
示例9: logs
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Override
public Iterable<Iterable<Directive>> logs() {
return new Mapped<Item, Iterable<Directive>>(
item -> new Directives()
.add("log")
.add("group").set(item.get("group").getS()).up()
.add("start").set(item.get("start").getN()).up()
.add("finish").set(item.get("finish").getN()).up()
.add("period").set(item.get("period").getS()).up()
.add("ocket").set(item.get("ocket").getS()).up()
.add("exit").set(item.get("exit").getN()).up()
.up(),
this.region.table("logs")
.frame()
.through(
new QueryValve()
.withIndexName("mine")
// @checkstyle MagicNumber (1 line)
.withLimit(20)
.withConsistentRead(false)
.withScanIndexForward(false)
.withSelect(Select.ALL_ATTRIBUTES)
)
.where("login", this.login)
);
}
示例10: recent
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
/**
* Recent artifacts..
* @return List of them
*/
public Iterable<Iterable<Directive>> recent() {
return new Mapped<>(
item -> {
final String[] parts = item.get("artifact").getS().split(":");
return new Directives()
.add("repo")
.add("group").set(parts[0]).up()
.add("artifact").set(parts[1]).up()
.up();
},
this.table.frame()
.where("good", "true")
.through(
new QueryValve()
.withScanIndexForward(false)
.withIndexName("recent")
.withConsistentRead(false)
// @checkstyle MagicNumber (1 line)
.withLimit(25)
.withAttributesToGet("artifact")
)
);
}
示例11: iterator
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Override
public Iterator<Directive> iterator() {
return new Directives()
.add("index")
.attr("artifact", "unknown")
.append(new Header())
.append(
new Joined<Directive>(
new Mapped<>(
Index::metric,
new Filtered<Path>(
path -> path.getFileName().toString().matches(
"^[A-Z].+\\.xml$"
),
new Directory(this.output)
)
)
)
)
.iterator();
}
示例12: code
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
@Override
public Input code() {
return new InputOf(
new FormattedText(
"%s\n\npublic interface %s {\n %s\n}\n",
"package eo;",
this.name,
new UncheckedText(
new JoinedText(
"\n ",
new Mapped<>(
this.methods,
mtd -> new UncheckedText(
new FormattedText("%s;", mtd.java())
).asString()
)
)
).asString().replace("\n", "\n ")
)
);
}
示例13: Ctor
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
/**
* Ctor.
*
* @param parameters Constructor parameters
* @param arguments Super constructor arguments.
*/
public Ctor(
final List<Parameter> parameters,
final Collection<Argument> arguments
) {
this.template = new UncheckedText(
new FormattedText(
"public %%s(%s) {\n this(%s);\n}",
new UncheckedText(
new JoinedText(
", ",
new Mapped<>(parameters, Parameter::java)
)
).asString(),
new UncheckedText(
new JoinedText(
", ",
new Mapped<>(arguments, Argument::java)
)
).asString()
)
).asString();
}
示例14: java
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
/**
* Convert it to Java.
* @return Java code
*/
public String java() {
return new UncheckedText(
new FormattedText(
"%s %s(%s)",
this.type,
this.name,
new UncheckedText(
new JoinedText(
", ",
new Mapped<>(
this.parameters,
Parameter::java
)
)
).asString()
)
).asString();
}
示例15: JoinedText
import org.cactoos.iterable.Mapped; //导入依赖的package包/类
/**
* Ctor.
* @param delimit Delimit among strings
* @param strs Strings to be joined
*/
public JoinedText(final String delimit, final Iterable<String> strs) {
this(
new TextOf(delimit),
new Mapped<>(
text -> new TextOf(text), strs
)
);
}