List of usage examples for java.util Objects isNull
public static boolean isNull(Object obj)
From source file:com.mac.holdempoker.app.hands.Boat.java
private Card[] findBoat() { Card[] trips = null;/*from w w w. ja v a2 s.co m*/ Card[] pair = null; for (Map.Entry<Rank, Card[]> entry : cards.entrySet()) { if (hasThree(entry.getValue())) { if (Objects.isNull(trips)) { trips = ArrayUtils.subarray(entry.getValue(), 0, 3); } } else if (hasTwo(entry.getValue())) { if (Objects.isNull(pair)) { pair = ArrayUtils.subarray(entry.getValue(), 0, 2); } } } if (Objects.nonNull(trips) && Objects.nonNull(pair)) { return ArrayUtils.addAll(trips, pair); } else { return null; } }
From source file:com.mac.holdempoker.app.hands.Quad.java
private Card[] findQuad() { Card highest = null;// ww w . j a va 2 s . co m Card[] quad = null; for (Entry<Rank, Card[]> entry : cards.entrySet()) { if (hasFour(entry.getValue())) { if (Objects.isNull(quad)) { quad = entry.getValue(); } } else if (Objects.isNull(highest)) { highest = getSingleCard(entry.getValue()); } } if (Objects.nonNull(quad) && Objects.nonNull(highest)) { return ArrayUtils.add(quad, highest); } else { return null; } }
From source file:pe.chalk.telegram.method.TextMessageSender.java
public TextMessageSender parseMode(final ParseMode parseMode) { if (Objects.isNull(parseMode)) this.parameters.remove("parse_mode"); else/*w w w. j ava2 s . co m*/ this.parameters.put("parse_mode", parseMode.getValue()); return this; }
From source file:com.mac.holdempoker.app.hands.TwoPair.java
private Card[] findTwoPair() { Card[] highPair = null;/*from w w w .ja v a2 s . c om*/ Card[] lowPair = null; Card highSingle = null; for (Map.Entry<Rank, Card[]> entry : cards.entrySet()) { // System.out.println(Arrays.toString(entry.getValue())); if (hasTwo(entry.getValue()) && Objects.isNull(highPair)) { highPair = ArrayUtils.subarray(entry.getValue(), 0, 2); } else if (hasTwo(entry.getValue()) && Objects.isNull(lowPair)) { lowPair = ArrayUtils.subarray(entry.getValue(), 0, 2); } else if (Objects.isNull(highSingle)) { highSingle = getSingleCard(entry.getValue()); } } // System.out.println("high: " + Arrays.toString(highPair) + "\tlow: " + Arrays.toString(lowPair) + "\tsingle: " + highSingle); if (Objects.nonNull(highPair) && Objects.nonNull(lowPair) && Objects.nonNull(highSingle)) { Card[] cs = ArrayUtils.addAll(lowPair, highPair); return ArrayUtils.add(cs, highSingle); } else { return null; } }
From source file:com.qpark.eip.core.sftp.LsClientCallback.java
/** * Create the {@link LsClientCallback}./*from w w w. j a v a2 s .com*/ * * @param path * the path to use when executing the ls command. * @param lsPattern * the file pattern to use when executing the ls command. */ public LsClientCallback(final String path, final String lsPattern) { this.path = path; this.lsPattern = Objects.isNull(lsPattern) || lsPattern.trim().length() == 0 ? "*" : lsPattern.trim(); }
From source file:com.mac.holdempoker.app.impl.SimpleRound.java
public void actionPerformed(Action action) { if (Objects.isNull(action)) { return;//from ww w .ja v a2 s .c o m } int indexOf = players.indexOf(action.getActingPlayer()); if (indexOf >= 0) { Player p = players.get(indexOf); if (action instanceof MoneyAction) { MoneyAction ma = (MoneyAction) action; p.decreaseStack(ma.getAmount()); pot.increasePot(ma); if (p.getStack() == 0) { p.addStatus(Status.ALL_IN); } } else { if (action.getActionName() == ActionName.FOLD) { players.remove(action.getActingPlayer()); if (players.size() == 1) { pot.singlePlayerWon(players.get(0)); notifyObserver(); } } } } }
From source file:io.redlink.solrlib.standalone.test.StandaloneSolrServer.java
@Override protected void before() throws Throwable { super.before(); if (Objects.isNull(solrHome)) { solrHome = Files.createTempDirectory("testSolr"); } else {//from w w w. java 2s . c o m Files.createDirectories(solrHome); deleteSolrHome = false; } try (PrintStream solrXml = new PrintStream(Files.newOutputStream(solrHome.resolve("solr.xml")))) { solrXml.println("<solr></solr>"); } jetty = new JettySolrRunner(solrHome.toAbsolutePath().toString(), jettyConfig); jetty.start(); logger.warn("Started StandaloneSolrServer {}", getBaseUrl()); }
From source file:com.mac.holdempoker.socket.HoldemEndpoint.java
@Override public void onMessage(WebSocket ws, String string) { try {/*from w w w . ja v a2s.c om*/ Message msg = decoder.decode(string); Header h = Header.getHeader(msg.getHeader()); if (Objects.isNull(h)) { return; } else if (h == Header.SIGN_IN) { boolean added = socketManager.addConnection(msg.getPid(), ws); if (!added) { System.out.println("Not added"); return; } } System.out.println(msg.getHeader()); System.out.println(msg.getPayload()); handler.handle(msg); String jo1 = JsonConverter.toJsonString(simpleGame.getGameState()); System.out.println(jo1); // ws.send(jo1); socketManager.sendToAllOpenConns(jo1); } catch (DecodeException ex) { ex.printStackTrace(); java.util.logging.Logger.getLogger(HoldemEndpoint.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { ex.printStackTrace(); java.util.logging.Logger.getLogger(HoldemEndpoint.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:co.mafiagame.engine.command.RegisterCommand.java
@Override public ResultMessage execute(RegisterCommandContext context) { Account account = saveAccount(context); StashedGame game = stashedGameContainer.getGame(context.getInterfaceContext()); if (Objects.isNull(game)) throw new RegisterBeforeStartException(); if (game.register(new Player(account))) commandExecutor.run(context.getInterfaceContext(), Constants.CMD.Internal.START_GAME, new StartGameCommandContext(context.getInterfaceContext(), game)); return new ResultMessage(new Message("player.successfully.registered").setArgs(account.getUsername()), ChannelType.GENERAL, context.getInterfaceContext()); }
From source file:org.kitodo.production.process.field.AdditionalField.java
/** * Set value./* w ww . j a v a2s. c o m*/ * * @param value * String */ public void setValue(String value) { if (Objects.isNull(value) || value.equals(this.initStart)) { value = ""; } if (value.startsWith(this.initStart)) { this.value = value + this.initEnd; } else { this.value = this.initStart + value + this.initEnd; } }