Back to project page Java-Yandex.Money-API-SDK.
The source code is released under:
MIT License
If you think the Android project Java-Yandex.Money-API-SDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ru.yandex.money.api.rights; // ww w . jav a 2s .c om import java.util.regex.Pattern; /** * ????????????? ??????? ????? ?? ??????? ? ?????? ????????????? ?? ???????????? * ?????? ??????? * @author dvmelnikov */ public abstract class AbstractLimitedPermission extends AbstractPermission { public static final Pattern SUM_PATTERN = Pattern.compile("\\d{1,15}(\\.\\d\\d)?"); protected String limit; protected AbstractLimitedPermission(String name) { super(name); } /** * ??????????? ????? ?? ????? ???????. ???????????? ????? ?????? ???????? ?? * ?????? ??????? ? ???????. * @param duration ?????? ??????? ? ??????? * @param sum ????? ?????? * @return ????? ?????? (?????) */ public Permission limit(int duration, String sum) { checkSum(sum); limit = "limit(" + duration + "," + sum + ")"; return this; } /** * ??????????? ????? ?? ????? ??????? ? ??????????? ????????. ??????? ?????????? ?? * ??????????? ?????? ???????????? ?????? * @param sum ????? ?????? * @return ????? ?????? (?????) */ public Permission limit(String sum) { checkSum(sum); limit = "limit(," + sum + ")"; return this; } private void checkSum(String sum) { if (!SUM_PATTERN.matcher(sum).matches()) { throw new IllegalArgumentException("sum is not valid"); } } @Override public String value() { String rule = super.value(); if (limit != null) { return rule + "." + limit; } return rule; } }