com.blade.kit.StringKit.isNotEmpty() - java examples

Here are the examples of the java api com.blade.kit.StringKit.isNotEmpty() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

19 View Complete Implementation : RouteActionArguments.java
Copyright Apache License 2.0
Author : lets-blade
private static String getDefaultValue(String defaultValue, Type argType) {
    if (argType.equals(String.clreplaced)) {
        if (StringKit.isNotEmpty(defaultValue)) {
            return defaultValue;
        }
        return null;
    }
    if ("".equals(defaultValue) && ReflectKit.isBasicType(argType)) {
        if (argType.equals(int.clreplaced) || argType.equals(long.clreplaced) || argType.equals(double.clreplaced) || argType.equals(float.clreplaced) || argType.equals(short.clreplaced) || argType.equals(byte.clreplaced)) {
            return "0";
        }
        if (argType.equals(boolean.clreplaced)) {
            return "false";
        }
        return "";
    }
    return defaultValue;
}

17 View Complete Implementation : Blade.java
Copyright Apache License 2.0
Author : lets-blade
/**
 * Load application environment configuration
 *
 * @param args command line parameters
 */
private void loadConfig(String[] args) {
    String bootConf = environment().get(ENV_KEY_BOOT_CONF, PROP_NAME);
    Environment bootEnv = Environment.of(bootConf);
    String envName = "default";
    if (null == bootEnv || bootEnv.isEmpty()) {
        bootEnv = Environment.of(PROP_NAME0);
    }
    if (!Objects.requireNonNull(bootEnv).isEmpty()) {
        Map<String, String> bootEnvMap = bootEnv.toMap();
        Set<Map.Entry<String, String>> entrySet = bootEnvMap.entrySet();
        entrySet.forEach(entry -> environment.set(entry.getKey(), entry.getValue()));
    }
    Map<String, String> argsMap = BladeKit.parseArgs(args);
    if (null != argsMap && !argsMap.isEmpty()) {
        log.info(" command line args: {}", JsonKit.toString(argsMap));
    }
    if (StringKit.isNotEmpty(argsMap.get(ENV_KEY_APP_ENV))) {
        envName = argsMap.get(ENV_KEY_APP_ENV);
        String evnFileName = "application-" + envName + ".properties";
        Environment customEnv = Environment.of(evnFileName);
        if (customEnv != null && !customEnv.isEmpty()) {
            customEnv.props().forEach((key, value) -> this.environment.set(key.toString(), value));
        } else {
            // compatible with older versions
            evnFileName = "app-" + envName + ".properties";
            customEnv = Environment.of(evnFileName);
            if (customEnv != null && !customEnv.isEmpty()) {
                Iterator<Map.Entry<Object, Object>> iterator = customEnv.props().entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry<Object, Object> next = iterator.next();
                    this.environment.set(next.getKey().toString(), next.getValue());
                }
            }
        }
        argsMap.remove(ENV_KEY_APP_ENV);
    }
    this.environment.set(ENV_KEY_APP_ENV, envName);
    this.register(this.environment);
    // load terminal param
    if (BladeKit.isEmpty(args)) {
        return;
    }
    Iterator<Map.Entry<String, String>> iterator = argsMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<String, String> next = iterator.next();
        this.environment.set(next.getKey(), next.getValue());
    }
}

16 View Complete Implementation : HttpRequest.java
Copyright Apache License 2.0
Author : lets-blade
@Override
public Map<String, Cookie> cookies() {
    if (!initCookie) {
        initCookie = true;
        String cookie = header(HttpConst.COOKIE_STRING);
        if (StringKit.isNotEmpty(cookie)) {
            ServerCookieDecoder.LAX.decode(cookie).forEach(this::parseCookie);
        }
    }
    return this.cookies;
}

15 View Complete Implementation : XssMiddleware.java
Copyright Apache License 2.0
Author : lets-blade
@Override
public boolean before(RouteContext context) {
    if (xssOption.isExclusion(context.uri())) {
        return true;
    }
    this.filterHeaders(context.headers());
    this.filterParameters(context.parameters());
    if (context.contentType().toLowerCase().contains("json")) {
        String body = context.bodyToString();
        if (StringKit.isNotEmpty(body)) {
            String filterBody = stripXSS(body);
            context.body(new StringBody(filterBody));
        }
    }
    return true;
}

14 View Complete Implementation : YouzanPayApi.java
Copyright MIT License
Author : biezhi
@Override
public boolean orderPaySuccess(String tradeNo) {
    AccessToken accessToken = getAccessToken();
    if (StringKit.isNotEmpty(accessToken.getError())) {
        throw new ValidatorException(accessToken.getErrorDescription());
    }
    String body = Request.get(YOUZAN_URL + "/youzan.trades.qr/3.0.0/get").userAgent("X-YZ-Client 2.0.0 - Java").contentType("application/json", "utf-8").form("access_token", accessToken.getAccess_token()).form("qr_id", tradeNo).connectTimeout(HTTP_TIME_OUT).readTimeout(HTTP_TIME_OUT).body();
    log.info("根据QRID查询订单响应: {}", body);
    return body.contains("TRADE_RECEIVED");
}

13 View Complete Implementation : MakeMoneyService.java
Copyright MIT License
Author : biezhi
public Page<Order> findOrders(OrderParam orderParam) {
    AnimaQuery<Order> query = select().from(Order.clreplaced);
    int page = Utils.parseInt(orderParam.getP(), 1);
    int limit = Utils.parseInt(Bootstrap.getGlobalConfig().get(Constant.PAGE_SIZE), 10);
    if (page < 1) {
        page = 1;
    }
    if (null != orderParam.getStatus()) {
        query.where(Order::getOrderStatus, orderParam.getStatus());
    }
    if (StringKit.isNotEmpty(orderParam.getPlatform())) {
        query.where(Order::getPlatform, orderParam.getPlatform());
    }
    return query.order(Order::getCreated, OrderBy.DESC).page(page, limit);
}

4 View Complete Implementation : YouzanPayApi.java
Copyright MIT License
Author : biezhi
@Override
public PayOrderResponse createQrCode(CreateOrderRequest createOrderRequest) {
    AccessToken accessToken = getAccessToken();
    if (StringKit.isNotEmpty(accessToken.getError())) {
        throw new ValidatorException(accessToken.getErrorDescription());
    }
    String body = Request.get(YOUZAN_URL + "/youzan.pay.qrcode/3.0.0/create").userAgent("X-YZ-Client 2.0.0 - Java").contentType("application/json", "utf-8").form("access_token", accessToken.getAccess_token()).form("qr_type", createOrderRequest.getQrType()).form("qr_price", createOrderRequest.getPrice()).form("qr_name", createOrderRequest.getQrName()).connectTimeout(HTTP_TIME_OUT).readTimeout(HTTP_TIME_OUT).body();
    log.info("创建二维码响应: {}", body);
    Response<QRCodeResponse> resultResponse = gson.fromJson(body, new TypeToken<Response<QRCodeResponse>>() {
    }.getType());
    QRCodeResponse response = resultResponse.getResponse();
    PayOrderResponse payOrderResponse = new PayOrderResponse();
    payOrderResponse.setTradeNo(response.getQrId().toString());
    payOrderResponse.setQrImg(response.getQrCode());
    payOrderResponse.setQrUrl(response.getQrUrl());
    return payOrderResponse;
}