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


Java Either.isRight方法代码示例

本文整理汇总了Java中scala.util.Either.isRight方法的典型用法代码示例。如果您正苦于以下问题:Java Either.isRight方法的具体用法?Java Either.isRight怎么用?Java Either.isRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scala.util.Either的用法示例。


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

示例1: getEnumCellEditor

import scala.util.Either; //导入方法依赖的package包/类
private CellEditor getEnumCellEditor(TreeNode node) {
    final ValueData vd = getVD(node);
    final EnumLike enumLike = (EnumLike)vd.element().thype();
    final Object[] values = Interop.toArray(enumLike.values(node));

    for(int i = 0; i < values.length; ++i) {
        Either<String, Object> e = enumLike.interpOut(node, values[i]);
        if(e.isRight()) {
            values[i] = Interop.literal(e.right().get());    
        }
        else {
            values[i] = e.left().get();
        }
    }

    return getSelectCellEditor(true, values);
}
 
开发者ID:insweat,项目名称:hssd,代码行数:18,代码来源:EntryEditorEditingSupport.java

示例2: aboutDataSource

import scala.util.Either; //导入方法依赖的package包/类
/**
 * Left is error Right is Tuple <dimensions, metrics>
 *
 * @param name
 * @param reqHeaders
 * @return
 */
public Either<String, Tuple2<List<String>, List<String>>> aboutDataSource(String name, Map<String, String> reqHeaders) {
    Either<String, Either<JSONArray, JSONObject>> resp = fireCommand("druid/coordinator/v1/metadata/datasources/" + name, null, reqHeaders);
    if (resp.isLeft()) {
        return new Left<>(resp.left().get());
    }
    Either<JSONArray, JSONObject> goodResp = resp.right().get();
    if (goodResp.isRight()) {
        JSONObject data = goodResp.right().get();
        if (data.has("segments")) {
            JSONArray segmentsArray = data.getJSONArray("segments");
            if (segmentsArray.length() == 0) {
                return new Left<>("No segments received..");
            }
            JSONObject firstItem = segmentsArray.getJSONObject(0);
            String dims = firstItem.getString("dimensions");
            String metrics = firstItem.getString("metrics");
            return new Right<>(new Tuple2<>(Arrays.asList(dims.split(",")), Arrays.asList(metrics.split(","))));
        } else {
            return new Left<>("No segments key in the response..");
        }
    }
    return new Left<>("Unexpected response " + goodResp.left().get().toString());
}
 
开发者ID:srikalyc,项目名称:Sql4D,代码行数:31,代码来源:CoordinatorAccessor.java

示例3: getValex

import scala.util.Either; //导入方法依赖的package包/类
private static Tuple2<String, Boolean> getValex(TreeNode vn) {
    ValueData vd = ValueData.of(vn);
    final Option<ValExpr> optVE = vd.valex()._1;
       final Thype thype = vd.element().thype();
       final boolean isSimple = thype instanceof SimpleThypeLike;

       if(isSimple && isOverridden(vn)) {
           String label;
           if(optVE.isDefined() && optVE.get().isError()){
               label = optVE.get().repr();
               return Interop.tuple(label, true);
           }
           else if(optVE.isDefined() && thype instanceof Interpreted) {
               label = optVE.get().repr();
               final Interpreted interp = (Interpreted)thype;
               Either<String, Object> e =
                       interp.interpOut(vn, optVE.get().value());
               if(e.isRight()) {
                   label = Interop.literal(e.right().get());
                   label = ValExpr.fmt(optVE.get().sym(), label);
                   return Interop.tuple(label, false);
               }
               else {
                   label = e.left().get();
                   return Interop.tuple(label, true);
               }
           }
           else {
               label = optVE.get().repr();
               return Interop.tuple(label, false);
           }
       }
       return Interop.tuple("", false);
}
 
开发者ID:insweat,项目名称:hssd,代码行数:35,代码来源:ValueTreeLP.java

示例4: readValue

import scala.util.Either; //导入方法依赖的package包/类
public static Object readValue(Object element) {
    final ValueData vd = getVD(element);
    final Thype thype = vd.element().thype();
    final Tuple2<Option<ValExpr>, Object> valex = vd.valex();

    if(!valex._1.isDefined() || (Boolean)valex._2) {
        return "";
    }

    ValExpr ve = valex._1.get();

    if(ve.isError()) {
        return "";
    }

    if(!(thype instanceof Interpreted)) {
        return ve.repr();
    }

    final Interpreted interp = (Interpreted)(thype);
    final Either<String, Object> e = interp.interpOut(element, ve.value());
    if(e.isRight()) {
        return ValExpr.fmt(ve.sym(), Interop.literal(e.right().get()));
    }
    else {
        return ValExpr.fmtErr(e.left().get());
    }
}
 
开发者ID:insweat,项目名称:hssd,代码行数:29,代码来源:EntryEditorEditingSupport.java

示例5: parseQuery

import scala.util.Either; //导入方法依赖的package包/类
private Expressions.Expression parseQuery(String dslQuery, QueryParams queryParams) throws DiscoveryException {
    Either<Parsers.NoSuccess, Expressions.Expression> either = QueryParser.apply(dslQuery, queryParams);
    if (either.isRight()) {
        Expressions.Expression expression = either.right().get();
        Expressions.Expression validatedExpression = QueryProcessor.validate(expression);
        return validatedExpression;
    } else {
        throw new DiscoveryException("Invalid expression : " + dslQuery + ". " + either.left());
    }

}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:12,代码来源:GraphBackedDiscoveryService.java


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