List of usage examples for java.util Objects isNull
public static boolean isNull(Object obj)
From source file:org.kitodo.production.converter.BeanConverter.java
/** * Get as string for bean convert./*from w w w .j a v a 2 s . co 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:com.qpark.eip.core.model.analysis.operation.GetServiceOperation.java
/** * @param message/*from w w w .j av a2 s .co m*/ * the {@link JAXBElement} containing a * {@link GetServiceRequestType}. * @return the {@link JAXBElement} with a {@link GetServiceResponseType}. */ @Override public final JAXBElement<GetServiceResponseType> invoke(final JAXBElement<GetServiceRequestType> message) { this.logger.debug("+getService"); GetServiceRequestType request = message.getValue(); GetServiceResponseType response = this.of.createGetServiceResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.setService(this.dao.getServiceByServiceId(modelVersion, request.getServiceId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getService duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getService #{}", response.getService() != null ? 1 : 0); } return this.of.createGetServiceResponse(response); }
From source file:com.qpark.eip.core.model.analysis.operation.GetDataTypeOperation.java
/** * @param message//from w w w . j a va 2 s . co m * the {@link JAXBElement} containing a * {@link GetDataTypeRequestType}. * @return the {@link JAXBElement} with a {@link GetDataTypeResponseType}. */ @Override public final JAXBElement<GetDataTypeResponseType> invoke(final JAXBElement<GetDataTypeRequestType> message) { this.logger.debug("+getDataType"); GetDataTypeRequestType request = message.getValue(); GetDataTypeResponseType response = this.of.createGetDataTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getDataType().addAll(this.dao.getDataTypesById(modelVersion, request.getId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getDataType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getDataType #{}", response.getDataType().size()); } return this.of.createGetDataTypeResponse(response); }
From source file:com.mac.holdempoker.app.hands.Boat.java
private void insert(Card[] ranked, Card insert) { for (int i = 1; i < ranked.length; i++) { if (Objects.isNull(ranked[i])) { ranked[i] = insert;/*from w w w .j ava 2 s. c o m*/ Arrays.sort(ranked, cardComparator()); break; } } }
From source file:org.kitodo.production.forms.LanguageForm.java
/** * Set session locale field id.// www .java2s . co m * * */ private void setSessionLocaleFieldId() { String key = ""; if (Objects.isNull(ServiceManager.getUserService().getAuthenticatedUser())) { key = ConfigCore.getParameterOrDefaultValue(ParameterCore.LANGUAGE_DEFAULT); } else { try { User user = ServiceManager.getUserService() .getById(ServiceManager.getUserService().getAuthenticatedUser().getId()); key = user.getLanguage(); } catch (DAOException e) { Helper.setErrorMessage("Error in retrieving user ", logger, e); } } Locale locale = new Locale.Builder().setLanguageTag(key).build(); if (LocaleUtils.isAvailableLocale(locale)) { FacesContext context = FacesContext.getCurrentInstance(); if (Objects.nonNull(context.getViewRoot())) { context.getViewRoot().setLocale(locale); context.getExternalContext().getSessionMap().put(SESSION_LOCALE_FIELD_ID, locale); } } }
From source file:com.mac.holdempoker.app.hands.Quad.java
private void insert(Card[] ranked, Card insert) { for (int i = 1; i < ranked.length; i++) { if (Objects.isNull(ranked[i])) { ranked[i] = insert;//w w w . j a v a 2 s . co m break; } } }
From source file:org.eclipse.winery.yaml.common.Utils.java
public static Path getTmpDir(Path path) { try {//from w w w . j av a 2 s.c o m if (Objects.isNull(tmpBase)) { tmpBase = Files.createTempDirectory("winery"); } } catch (Exception e) { logger.error("Failed to create tmp dir with name 'winery'", e); } Path result = tmpBase.resolve(path); try { Files.createDirectories(result); } catch (IOException e) { logger.error("Failed to create tmp dir '{}':\n {}", result, e); } return result; }
From source file:com.qpark.eip.core.model.analysis.operation.GetServiceIdOperation.java
/** * @param message/* ww w . j a va 2s .c om*/ * the {@link JAXBElement} containing a * {@link GetServiceIdRequestType}. * @return the {@link JAXBElement} with a {@link GetServiceIdResponseType}. */ @Override public final JAXBElement<GetServiceIdResponseType> invoke(final JAXBElement<GetServiceIdRequestType> message) { this.logger.debug("+getServiceId"); final GetServiceIdRequestType request = message.getValue(); final GetServiceIdResponseType response = this.of.createGetServiceIdResponseType(); final long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getServiceId().addAll(this.dao.getServiceIds(modelVersion)); } catch (final Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getServiceId duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getServiceId #{}", response.getServiceId().size()); } return this.of.createGetServiceIdResponse(response); }
From source file:com.qpark.eip.core.model.analysis.operation.GetClusterOperation.java
/** * @param message//from w w w. j a va 2 s.c om * the {@link JAXBElement} containing a * {@link GetClusterRequestType}. * @return the {@link JAXBElement} with a {@link GetComplexTypeResponseType} * . */ @Override public JAXBElement<GetClusterResponseType> invoke(final JAXBElement<GetClusterRequestType> message) { this.logger.debug("+getCluster"); GetClusterRequestType request = message.getValue(); GetClusterResponseType response = this.of.createGetClusterResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.setCluster(this.dao.getClusterByTargetNamespace(modelVersion, request.getTargetNamespace())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getCluster duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getCluster #{}", response.getCluster() == null ? 0 : 1); } return this.of.createGetClusterResponse(response); }
From source file:com.qpark.eip.core.model.analysis.operation.GetComplexTypeOperation.java
/** * @param message/*from w ww .j a va2 s . c o m*/ * the {@link JAXBElement} containing a * {@link GetComplexTypeRequestType}. * @return the {@link JAXBElement} with a {@link GetComplexTypeResponseType} * . */ @Override public final JAXBElement<GetComplexTypeResponseType> invoke( final JAXBElement<GetComplexTypeRequestType> message) { this.logger.debug("+getComplexType"); GetComplexTypeRequestType request = message.getValue(); GetComplexTypeResponseType response = this.of.createGetComplexTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getComplexType().addAll(this.dao.getComplexTypesById(modelVersion, request.getId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getComplexType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getComplexType #{}", response.getComplexType().size()); } return this.of.createGetComplexTypeResponse(response); }