play.libs.Scala.noMatch()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中play.libs.Scala.noMatch()方法的一些代码示例,展示了Scala.noMatch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scala.noMatch()方法的具体详情如下:
包路径:play.libs.Scala
类名称:Scala
方法名:noMatch

Scala.noMatch介绍

[英]Throw this exception to indicate that a partial function doesn't match.
[中]抛出此异常以指示部分函数不匹配。

代码示例

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * Acceptor for JSON WebSockets.
 *
 * @param in The class of the incoming messages, used to decode them from the JSON.
 * @param <In> The websocket's input type (what it receives from clients)
 * @param <Out> The websocket's output type (what it writes to clients)
 * @return The WebSocket acceptor.
 */
public static <In, Out> MappedWebSocketAcceptor<In, Out> json(Class<In> in) {
  return new MappedWebSocketAcceptor<>(Scala.partialFunction(message -> {
    try {
      if (message instanceof Message.Binary) {
        return F.Either.Left(play.libs.Json.mapper().readValue(((Message.Binary) message).data().iterator().asInputStream(), in));
      } else if (message instanceof Message.Text) {
        return F.Either.Left(play.libs.Json.mapper().readValue(((Message.Text) message).data(), in));
      }
    } catch (Exception e) {
      return F.Either.Right(new Message.Close(CloseCodes.Unacceptable(), e.getMessage()));
    }
    throw Scala.noMatch();
  }), outMessage -> {
    try {
      return new Message.Text(play.libs.Json.mapper().writeValueAsString(outMessage));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  });
}

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * Acceptor for JSON WebSockets.
 *
 * @param in The class of the incoming messages, used to decode them from the JSON.
 * @param <In> The websocket's input type (what it receives from clients)
 * @param <Out> The websocket's output type (what it writes to clients)
 * @return The WebSocket acceptor.
 */
public static <In, Out> MappedWebSocketAcceptor<In, Out> json(Class<In> in) {
  return new MappedWebSocketAcceptor<>(Scala.partialFunction(message -> {
    try {
      if (message instanceof Message.Binary) {
        return F.Either.Left(play.libs.Json.mapper().readValue(((Message.Binary) message).data().iterator().asInputStream(), in));
      } else if (message instanceof Message.Text) {
        return F.Either.Left(play.libs.Json.mapper().readValue(((Message.Text) message).data(), in));
      }
    } catch (Exception e) {
      return F.Either.Right(new Message.Close(CloseCodes.Unacceptable(), e.getMessage()));
    }
    throw Scala.noMatch();
  }), outMessage -> {
    try {
      return new Message.Text(play.libs.Json.mapper().writeValueAsString(outMessage));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  });
}

代码示例来源:origin: com.typesafe.play/play

/**
 * Acceptor for JSON WebSockets.
 *
 * @param in The class of the incoming messages, used to decode them from the JSON.
 * @param <In> The websocket's input type (what it receives from clients)
 * @param <Out> The websocket's output type (what it writes to clients)
 * @return The WebSocket acceptor.
 */
public static <In, Out> MappedWebSocketAcceptor<In, Out> json(Class<In> in) {
  return new MappedWebSocketAcceptor<>(Scala.partialFunction(message -> {
    try {
      if (message instanceof Message.Binary) {
        return F.Either.Left(play.libs.Json.mapper().readValue(((Message.Binary) message).data().iterator().asInputStream(), in));
      } else if (message instanceof Message.Text) {
        return F.Either.Left(play.libs.Json.mapper().readValue(((Message.Text) message).data(), in));
      }
    } catch (Exception e) {
      return F.Either.Right(new Message.Close(CloseCodes.Unacceptable(), e.getMessage()));
    }
    throw Scala.noMatch();
  }), outMessage -> {
    try {
      return new Message.Text(play.libs.Json.mapper().writeValueAsString(outMessage));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  });
}

代码示例来源:origin: com.typesafe.play/play_2.12

return x.left.get();
} else {
  throw Scala.noMatch();
  return x.right.get();
} else {
  throw Scala.noMatch();

代码示例来源:origin: com.typesafe.play/play

return x.left.get();
} else {
  throw Scala.noMatch();
  return x.right.get();
} else {
  throw Scala.noMatch();

代码示例来源:origin: com.typesafe.play/play_2.11

return x.left.get();
} else {
  throw Scala.noMatch();
  return x.right.get();
} else {
  throw Scala.noMatch();

相关文章