本文整理匯總了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;",
"}",
"}"
)
)
)
);
}