當前位置: 首頁>>代碼示例>>Java>>正文


Java UncheckedText類代碼示例

本文整理匯總了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  ")
        )
    );
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:22,代碼來源:JavaInterface.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:29,代碼來源:Ctor.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:23,代碼來源:Method.java

示例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()
        )
    );
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:27,代碼來源:JavaClassTest.java

示例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()
        )
    );
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:22,代碼來源:JavaInterfaceTest.java

示例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"
        )
    );
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:20,代碼來源:AttributeTest.java

示例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);
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:24,代碼來源:CompileMojo.java

示例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()
    );
}
 
開發者ID:yegor256,項目名稱:cactoos,代碼行數:9,代碼來源:InputHasContent.java

示例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  ")
        )
    );
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:15,代碼來源:JavaClass.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:36,代碼來源:PrimaryConstructor.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:15,代碼來源:MethodImpl.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:37,代碼來源:ObjectBody.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:14,代碼來源:Parameter.java

示例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();
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:20,代碼來源:CpObject.java

示例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;",
                    "}",
                    "}"
                )
            )
        )
    );
}
 
開發者ID:yegor256,項目名稱:eo,代碼行數:38,代碼來源:JavaClassTest.java


注:本文中的org.cactoos.text.UncheckedText類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。