本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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());
}
}
示例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());
}
}