List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:co.mafiagame.telegraminterface.inputhandler.UpdateController.java
@SuppressWarnings("InfiniteLoopStatement") @PostConstruct/*from ww w .jav a2 s . c o m*/ public void init() { Thread thread = new Thread(() -> { try { long offset = 1; Thread.sleep(TimeUnit.MINUTES.toMillis(2)); while (true) { try { RestTemplate restTemplate = new RestTemplate(); setErrorHandler(restTemplate); TResult tResult = restTemplate.getForObject( telegramUrl + telegramToken + "/getUpdates?offset=" + String.valueOf(offset + 1), TResult.class); for (TUpdate update : tResult.getResult()) { if (offset < update.getId()) { offset = update.getId(); if (Objects.nonNull(update.getMessage())) { logger.info("receive: {}", update); commandDispatcher.handle(update); } logger.info("offset set to {}", offset); } } Thread.sleep(TimeUnit.MILLISECONDS.toMillis(500)); } catch (Exception e) { logger.error(e.getMessage(), e); } } } catch (InterruptedException e) { e.printStackTrace(); } }); thread.start(); }
From source file:com.ben12.openhab.model.util.BeanCopy.java
private boolean isCopyable(final Object value) { boolean copyable = false; if (value != null) { final Class<?> type = value.getClass(); final XmlRootElement xmlElement = type.getAnnotation(XmlRootElement.class); copyable = Objects.nonNull(xmlElement); }/*from w w w. j a v a 2 s . c o m*/ return copyable; }
From source file:com.mac.holdempoker.socket.SocketManager.java
private boolean isValidString(String str) { return Objects.nonNull(str) && !str.isEmpty(); }
From source file:com.mac.halendpoint.endpoints.HalSocket.java
@Override public void onClose(WebSocket ws, int i, String string, boolean bln) { if (Objects.nonNull(ws)) { socketManager.removeSocket(ws);//from w ww. java2s . co m } }
From source file:com.mac.holdempoker.app.hands.TwoPair.java
private Card getSingleCard(Card[] all) { for (Card c : all) { if (Objects.nonNull(c)) { return c; }/*ww w.ja va 2s .c om*/ } return null; }
From source file:com.mac.holdempoker.socket.SocketManager.java
private boolean isValidList(List<? extends Object> list) { return Objects.nonNull(list) && !list.isEmpty(); }
From source file:org.kitodo.production.ldap.LdapUser.java
/** * configure LdapUser with User data.//ww w . j a v a2s . c o m * * @param user * User object * @param inPassword * String * @param inUidNumber * String */ public void configure(User user, String inPassword, String inUidNumber) throws NamingException, NoSuchAlgorithmException { MD4 digester = new MD4(); if (!user.getLdapGroup().getLdapServer().isReadOnly()) { if (Objects.nonNull(user.getLdapLogin())) { this.ldapLogin = user.getLdapLogin(); } else { this.ldapLogin = user.getLogin(); } LdapGroup ldapGroup = user.getLdapGroup(); if (Objects.isNull(ldapGroup.getObjectClasses())) { throw new NamingException("no objectclass defined"); } prepareAttributes(ldapGroup, user, inUidNumber); /* * Samba passwords */ /* LanMgr */ try { this.attributes.put("sambaLMPassword", toHexString(lmHash(inPassword))); } catch (InvalidKeyException | NoSuchPaddingException | BadPaddingException | IllegalBlockSizeException | RuntimeException e) { logger.error(e.getMessage(), e); } /* NTLM */ byte[] hmm = digester.digest(inPassword.getBytes(StandardCharsets.UTF_16LE)); this.attributes.put("sambaNTPassword", toHexString(hmm)); /* * Encryption of password und Base64-Enconding */ String passwordEncrytion = ldapGroup.getLdapServer().getPasswordEncryption().getTitle(); MessageDigest md = MessageDigest.getInstance(passwordEncrytion); md.update(inPassword.getBytes(StandardCharsets.UTF_8)); String encodedDigest = new String(Base64.encodeBase64(md.digest()), StandardCharsets.UTF_8); this.attributes.put("userPassword", "{" + passwordEncrytion + "}" + encodedDigest); } }
From source file:com.amanmehara.programming.android.adapters.DetailAdapter.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from w w w.j a v a2 s.com*/ public void onBindViewHolder(ViewHolder viewHolder, int i) { WebSettings webSettings = viewHolder.fileContentView.getSettings(); webSettings.setJavaScriptEnabled(true); try { JSONObject jsonObject = programContents.getJSONObject(i); viewHolder.fileNameView.setText(jsonObject.getString("name")); String url = jsonObject.getString("url"); String response = sharedPreferences.getString(url, null); if (Objects.nonNull(response)) { getContentResponseCallback(url, true, viewHolder).accept(response); } else { new GithubAPIClient(activity, getContentResponseCallback(url, false, viewHolder)) .execute(withAccessToken(url)); } } catch (JSONException e) { Log.e(TAG, e.getMessage()); } }
From source file:co.mafiagame.engine.command.StartStashedGameCommand.java
private void validate(StartStashedGameCommandContext context) { if (context.getDetectiveNum() > 1) throw new MoreThanOneDetectiveException(); if (context.getDoctorNum() > 1) throw new MoreThanOneDoctorException(); if (context.getMafiaNum() < 1) throw new ZeroMafiaException(); if (Objects.nonNull(gameContainer.getGame(context.getInterfaceContext()))) throw new GameAlreadyStartedException(); }
From source file:com.caricah.iotracah.server.mqttserver.MqttServer.java
/** * <code>terminate</code> halts excecution of this plugin. * This provides a clean way to exit /stop operations of this particular plugin. */// www .j a v a 2 s. co m @Override public void terminate() { log.info(" terminate : stopping any processing. "); if (Objects.nonNull(serverImpl)) { serverImpl.terminate(); } }