예제 #1
0
  public static TwitterBet unmarshalControl(String tweet) {

    String tw = tweet.replace(",", ".").replaceAll(" +", " ").toUpperCase();

    Preconditions.checkArgument(tw.matches(tweetControlPattern), "TWEET INVALIDO");

    String str = tw.split(" ")[0];
    String[] lottery = tw.substring(str.length() + 1).split(" ");

    DateTime date = lottery.length > 2 ? BirjanUtils.getDate(lottery[2]) : new DateTime();

    Collection<String> lotteries = select(lotteryNames, lottery[0]);
    Collection<String> variants = lottery.length > 1 ? select(variantNames, lottery[1]) : null;

    TwitterBet bet = new TwitterBet(null, null, null, date, lotteries, variants);

    return bet;
  }
예제 #2
0
  public static TwitterBet unmarshalBet(String tweet) {

    String tw = tweet.replace(",", ".").replaceAll(" +", " ").toUpperCase();

    Preconditions.checkArgument(tw.matches(tweetBetPattern), "TWEET INVALIDO");

    String str = tw.split(" ([NP]{1,2}|T)")[0];
    String[] data = str.split(" ");
    String[] lottery = tw.substring(str.length() + 1).split(" ");

    String number = "xxx" + data[0];
    number = number.substring(number.length() - 4, number.length());
    Integer position = data.length > 2 ? Integer.parseInt(data[1]) : 1;
    Float amount = data.length > 2 ? Float.parseFloat(data[2]) : Float.parseFloat(data[1]);
    DateTime date = lottery.length > 2 ? BirjanUtils.getDate(lottery[2]) : new DateTime();

    Collection<String> lotteries = select(lotteryNames, lottery[0]);
    Collection<String> variants = lottery.length > 1 ? select(variantNames, lottery[1]) : null;

    TwitterBet bet = new TwitterBet(number, position, amount, date, lotteries, variants);

    return bet;
  }