本文整理汇总了Java中org.cactoos.text.UncheckedText类的典型用法代码示例。如果您正苦于以下问题:Java UncheckedText类的具体用法?Java UncheckedText怎么用?Java UncheckedText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UncheckedText类属于org.cactoos.text包,在下文中一共展示了UncheckedText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: code
import org.cactoos.text.UncheckedText; //导入依赖的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 ")
)
);
}
示例2: Ctor
import org.cactoos.text.UncheckedText; //导入依赖的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();
}
示例3: java
import org.cactoos.text.UncheckedText; //导入依赖的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();
}
示例4: classPath
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Test class path.
*/
@Test
public void classPath() {
final String name = "Book";
MatcherAssert.assertThat(
new JavaClass(
name,
new StickyList<>("Text"),
new ObjectBody(
new StickyList<>(),
new StickyList<>(),
new StickyList<>()
)
).path(),
Matchers.equalTo(
new UncheckedText(
new FormattedText(
"%s.java",
name
)
).asString()
)
);
}
示例5: interfacePath
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Test interface path.
*/
@Test
public void interfacePath() {
final String name = "Book";
MatcherAssert.assertThat(
new JavaInterface(
name,
new StickyList<>()
).path(),
Matchers.equalTo(
new UncheckedText(
new FormattedText(
"%s.java",
name
)
).asString()
)
);
}
示例6: javaCode
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Generates java code with provided format.
*/
@Test
public void javaCode() {
MatcherAssert.assertThat(
new Attribute(
"Type",
"name"
).java(
(type, name) -> new UncheckedText(
new FormattedText("%s:%s", type, name)
).asString()
),
Matchers.equalTo(
"Type:name"
)
);
}
示例7: compile
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Compile one EO file.
* @param file EO file
*/
private void compile(final Path file) {
try {
new Program(
new InputOf(file),
this.targetDirectory.toPath()
).compile();
} catch (final IOException ex) {
throw new IllegalStateException(
new UncheckedText(
new FormattedText(
"Can't compile %s into %s",
file, this.targetDirectory
)
).asString(),
ex
);
}
Logger.info(this, "%s compiled to %s", file, this.targetDirectory);
}
示例8: matchesSafely
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
@Override
public boolean matchesSafely(final Input item) {
return this.matcher.matches(
new UncheckedText(
new TextOf(item)
).asString()
);
}
示例9: code
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
@Override
public Input code() {
return new InputOf(
new FormattedText(
"%s\n\npublic final class %s implements %s {\n %s\n}\n",
"package eo;",
this.name,
new UncheckedText(
new JoinedText(", ", this.ifaces)
).asString(),
this.body.java(this.name).replace("\n", "\n ")
)
);
}
示例10: code
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Generate constructor java code.
*
* @return Java code for constructor.
*/
public String code() {
return new UncheckedText(
new FormattedText(
"public %s(%s) {\n %s \n}",
this.name,
new UncheckedText(
new JoinedText(
", ",
new Mapped<>(
this.attributes,
attr -> attr.java(
PrimaryConstructor.CTOR_PARAM_FORMAT
)
)
)
).asString(),
new UncheckedText(
new JoinedText(
"\n",
new Mapped<>(
this.attributes,
attr -> attr.java(
PrimaryConstructor.CTOR_INIT_FORMAT
)
)
)
).asString()
)
).asString();
}
示例11: java
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Method declaration and body code.
*
* @return Java code.
*/
public String java() {
return new UncheckedText(
new FormattedText(
"public %s {\n return %s;\n}",
this.declaration.java(),
this.argument.java()
)
).asString();
}
示例12: java
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Java code for object body.
*
* @param name Java class name
* @return Java code
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public String java(final String name) {
return new UncheckedText(
new JoinedText(
"\n",
new UncheckedText(
new JoinedText(
"\n",
new Mapped<>(
this.attrs,
attr -> attr.java(ObjectBody.FIELD_FORMAT)
)
)
).asString(),
new UncheckedText(
new JoinedText(
"\n",
new Mapped<>(this.ctors, ctor -> ctor.java(name))
)
).asString(),
new PrimaryConstructor(name, this.attrs).code(),
new UncheckedText(
new JoinedText(
"\n",
new Mapped<>(this.methods, MethodImpl::java)
)
).asString()
)
).asString();
}
示例13: java
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Convert it to Java.
* @return Java code
*/
public String java() {
return new UncheckedText(
new FormattedText(
"final %s %s",
this.type,
this.name
)
).asString();
}
示例14: java
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Java code for object copying.
*
* @return Java code
*/
public String java() {
return new UncheckedText(
new FormattedText(
"new %s(%s)",
this.name,
new UncheckedText(
new JoinedText(
", ",
new Mapped<>(this.args, Argument::java)
)
).asString()
)
).asString();
}
示例15: fields
import org.cactoos.text.UncheckedText; //导入依赖的package包/类
/**
* Test class with fields.
*/
@Test
public void fields() {
final String name = "error";
final Collection<String> types = new StickyList<>("Error");
MatcherAssert.assertThat(
new JavaClass(
name,
types,
new ObjectBody(
new StickyList<>(new Attribute("Text", "msg")),
new StickyList<>(),
new StickyList<>()
)
).code(),
new InputHasContent(
Matchers.stringContainsInOrder(
new StickyList<>(
"public final class",
name,
"implements Error",
"{",
"private final Text msg;",
new UncheckedText(
new FormattedText("public %s(final Text msg)", name)
).asString(),
"{",
"this.msg = msg;",
"}",
"}"
)
)
)
);
}