当前位置: 首页>>代码示例>>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;未经允许,请勿转载。