List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.kitodo.production.process.TitleGenerator.java
/** * Create Atstsl./*from w w w . ja v a 2s .com*/ * * @param title * String * @param author * String * @return String */ public static String createAtstsl(String title, String author) { StringBuilder result = new StringBuilder(8); if (Objects.nonNull(author) && !author.trim().isEmpty()) { result.append(getPartString(author, 4)); result.append(getPartString(title, 4)); } else { StringTokenizer titleWords = new StringTokenizer(title); int wordNo = 1; while (titleWords.hasMoreTokens() && wordNo < 5) { String word = titleWords.nextToken(); switch (wordNo) { case 1: result.append(getPartString(word, 4)); break; case 2: case 3: result.append(getPartString(word, 2)); break; case 4: result.append(getPartString(word, 1)); break; default: break; } wordNo++; } } return result.toString().replaceAll("[\\W]", ""); // delete umlauts etc. }
From source file:org.apache.streams.neo4j.http.Neo4jHttpClient.java
public void start() throws Exception { Objects.nonNull(config); assertThat("config.getScheme().startsWith(\"http\")", config.getScheme().startsWith("http")); LOGGER.info("Neo4jConfiguration.start {}", config); Objects.nonNull(client);// w ww.j av a2 s. co m }
From source file:br.com.elotech.sits.service.AbstractService.java
public WebServiceTemplate getWebServiceTemplateByXSD(Node node) { if (Objects.nonNull(node) && Objects.nonNull(node.getNodeValue()) && node.getNodeValue().contains(XSD_VERSAO_2_03)) { return webServiceVersao203Template; }/*from ww w .j av a 2s . c o m*/ return webServiceTemplate; }
From source file:com.mac.holdempoker.app.hands.TwoPair.java
private Card[] findTwoPair() { Card[] highPair = null;// ww w .j av a2 s . c o m 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:org.kitodo.production.converter.BeanConverter.java
/** * Get as string for bean convert./* w ww . j a va2 s . c o m*/ * * @param value * bean to be converted * @param translationKey * for possible error message * @return null when bean is null, otherwise string id or string representation * of value */ protected String getAsString(Object value, String translationKey) { if (Objects.isNull(value)) { return null; } else if (value instanceof BaseBean) { Integer beanId = ((BaseBean) value).getId(); if (Objects.nonNull(beanId)) { return String.valueOf(beanId); } return "0"; } else if (value instanceof String) { return (String) value; } else { throw new ConverterException(Helper.getTranslation("errorConvert", Arrays.asList(value.getClass().getCanonicalName(), translationKey))); } }
From source file:org.kitodo.production.process.TitleGenerator.java
/** * Generate title for process./*w w w .j a v a 2s . c o m*/ * * @param titleDefinition * definition for title to generation * @param genericFields * Map of Strings * @return String */ public String generateTitle(String titleDefinition, Map<String, String> genericFields) throws ProcessGenerationException { String currentAuthors = getCurrentValue(LIST_OF_CREATORS); String currentTitle = getCurrentValue(TITLE_DOC_MAIN); StringBuilder newTitle = new StringBuilder(); StringTokenizer tokenizer = new StringTokenizer(titleDefinition, "+"); // parse the band title while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); // if the string begins with ' and ends with ' then take over the content if (token.startsWith("'") && token.endsWith("'")) { newTitle.append(token, 1, token.length() - 1); } else if (token.startsWith("#")) { // resolve strings beginning with # from generic fields if (Objects.nonNull(genericFields)) { String genericValue = genericFields.get(token); if (Objects.nonNull(genericValue)) { newTitle.append(genericValue); } } } else { newTitle.append(evaluateAdditionalFields(currentTitle, currentAuthors, token)); } } if (newTitle.toString().endsWith("_")) { newTitle.setLength(newTitle.length() - 1); } // remove non-ascii characters for the sake of TIFF header limits return newTitle.toString().replaceAll("[^\\p{ASCII}]", ""); }
From source file:pe.chalk.telegram.type.Update.java
public boolean hasChosenInlineResult() { return Objects.nonNull(this.getChosenInlineResult()); }
From source file:com.fantasy.stataggregator.workers.GameDataRetrieverTask.java
/** * Sets the statistical year to be requested. * * @param year/*ww w . j av a 2 s . c o m*/ * @throws java.text.ParseException */ @Override public void setYear(int year) throws ParseException { if (Objects.nonNull(ctx)) { this.year = year; isTaskComplete = false; GameScheduleRepository gsr = ctx.getBean(GameScheduleRepository.class); if (year == Integer.MAX_VALUE) { schedules = gsr.findAll(); } else { SimpleDateFormat sdf = ctx.getBean(SimpleDateFormat.class); sdf.applyLocalizedPattern("yyyyMMdd"); Date min = sdf.parse(year + START_OF_YEAR); Date max = sdf.parse(year + END_OF_YEAR); CriteriaBuilder cb = gsr.getCriteriaBuilder(); CriteriaQuery<GameSchedule> cq = gsr.getCriteriaQuery(); Root<GameSchedule> gameSchedule = gsr.getRoot(); cq.select(gameSchedule).where(cb.between(gameSchedule.get(GameSchedule_.gamedate), min, max)) .orderBy(cb.asc(gameSchedule.get(GameSchedule_.gameid))); schedules = gsr.getCriteriaList(cq); System.out.println(schedules.size()); } } }
From source file:org.apache.streams.riak.http.RiakHttpClient.java
public void start() throws Exception { Objects.nonNull(config); assert (config.getScheme().startsWith("http")); URIBuilder uriBuilder = new URIBuilder(); uriBuilder.setScheme(config.getScheme()); uriBuilder.setHost(config.getHosts().get(0)); uriBuilder.setPort(config.getPort().intValue()); baseURI = uriBuilder.build();//from www .j ava 2s. c o m client = HttpClients.createDefault(); }
From source file:com.mac.holdempoker.app.hands.Quad.java
private boolean hasFour(Card[] all) { int index = 0; for (Card c : all) { if (Objects.nonNull(c)) { index++;/*from ww w .j ava 2 s. c om*/ if (index == 4) { return true; } } } return false; }