当前位置: 首页>>代码示例>>Java>>正文


Java StickyMap类代码示例

本文整理汇总了Java中org.cactoos.map.StickyMap的典型用法代码示例。如果您正苦于以下问题:Java StickyMap类的具体用法?Java StickyMap怎么用?Java StickyMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StickyMap类属于org.cactoos.map包,在下文中一共展示了StickyMap类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertsMapToProperties

import org.cactoos.map.StickyMap; //导入依赖的package包/类
@Test
public void convertsMapToProperties() {
    MatcherAssert.assertThat(
        "Can't convert map to properties",
        new PropertiesOf(
            new StickyMap<>(
                new MapOf<Integer, String>(
                    new MapEntry<>(0, "hello, world"),
                    new MapEntry<>(1, "how are you?")
                )
            )
        ),
        new ScalarHasValue<>(
            new MatcherOf<Properties>(
                props -> {
                    return props.getProperty("0").endsWith(", world");
                }
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:22,代码来源:PropertiesOfTest.java

示例2: pay

import org.cactoos.map.StickyMap; //导入依赖的package包/类
@Override
public void pay(final long cents, final String token, final String email)
    throws IOException {
    final String customer;
    try {
        customer = Customer.create(
            new StickyMap<String, Object>(
                new MapEntry<>("email", email),
                new MapEntry<>("source", token)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        ).getId();
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        new AttributeUpdates()
            .with(
                "stripe_cents",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withN(Long.toString(cents))
                ).withAction(AttributeAction.PUT)
            )
            .with(
                "stripe_customer",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withS(customer)
                ).withAction(AttributeAction.PUT)
            )
    );
    this.rebill();
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:37,代码来源:DyScript.java

示例3: rebill

import org.cactoos.map.StickyMap; //导入依赖的package包/类
/**
 * Charge him again.
 * @throws IOException If fails
 */
private void rebill() throws IOException {
    final Item item = this.item();
    final Long cents = Long.parseLong(item.get("stripe_cents").getN());
    final String customer = item.get("stripe_customer").getS();
    try {
        Charge.create(
            new StickyMap<String, Object>(
                new MapEntry<>("amount", cents),
                new MapEntry<>("currency", "usd"),
                new MapEntry<>(
                    "description",
                    String.format("ThreeCopies: %s", this.name)
                ),
                new MapEntry<>("customer", customer)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        );
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        "paid",
        new AttributeValueUpdate().withValue(
            new AttributeValue().withN(
                Long.toString(cents * TimeUnit.HOURS.toSeconds(1L))
            )
        ).withAction(AttributeAction.ADD)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:38,代码来源:DyScript.java


注:本文中的org.cactoos.map.StickyMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。