List of usage examples for org.springframework.util ObjectUtils nullSafeEquals
public static boolean nullSafeEquals(@Nullable Object o1, @Nullable Object o2)
From source file:spring.osgi.io.OsgiBundleResource.java
/** * <p/> This implementation compares the underlying bundle and path * locations.//from w ww . ja v a 2 s . co m */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof OsgiBundleResource) { OsgiBundleResource otherRes = (OsgiBundleResource) obj; return (this.path.equals(otherRes.path) && ObjectUtils.nullSafeEquals(this.bundle, otherRes.bundle)); } return false; }
From source file:com.springsource.hq.plugin.tcserver.serverconfig.services.connector.HttpConnector.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/* ww w. j a va 2 s.c om*/ if (!(obj instanceof HttpConnector)) { return false; } HttpConnector connector = (HttpConnector) obj; return ObjectUtils.nullSafeEquals(this.getAcceptCount(), connector.getAcceptCount()) && ObjectUtils.nullSafeEquals(this.getAlgorithm(), connector.getAlgorithm()) && ObjectUtils.nullSafeEquals(this.getKeyAlias(), connector.getKeyAlias()) && ObjectUtils.nullSafeEquals(this.getKeystoreFile(), connector.getKeystoreFile()) && ObjectUtils.nullSafeEquals(this.getKeystorePass(), connector.getKeystorePass()) && ObjectUtils.nullSafeEquals(this.getMaxKeepAliveRequests(), connector.getMaxKeepAliveRequests()) && ObjectUtils.nullSafeEquals(this.getProtocol(), connector.getProtocol()) && ObjectUtils.nullSafeEquals(this.getSecure(), connector.getSecure()) && ObjectUtils.nullSafeEquals(this.getSSLEnabled(), connector.getSSLEnabled()) && ObjectUtils.nullSafeEquals(this.getSSLCACertificateFile(), connector.getSSLCACertificateFile()) && ObjectUtils.nullSafeEquals(this.getSSLCACertificatePath(), connector.getSSLCACertificatePath()) && ObjectUtils.nullSafeEquals(this.getSSLCARevocationFile(), connector.getSSLCARevocationFile()) && ObjectUtils.nullSafeEquals(this.getSSLCARevocationPath(), connector.getSSLCARevocationPath()) && ObjectUtils.nullSafeEquals(this.getSSLCertificateChainFile(), connector.getSSLCertificateChainFile()) && ObjectUtils.nullSafeEquals(this.getSSLCertificateFile(), connector.getSSLCertificateFile()) && ObjectUtils.nullSafeEquals(this.getSSLCertificateKeyFile(), connector.getSSLCertificateKeyFile()) && ObjectUtils.nullSafeEquals(this.getSSLCipherSuite(), connector.getSSLCipherSuite()) && ObjectUtils.nullSafeEquals(this.getSSLPassword(), connector.getSSLPassword()) && ObjectUtils.nullSafeEquals(this.getSSLProtocol(), connector.getSSLProtocol()) && ObjectUtils.nullSafeEquals(this.getSSLVerifyClient(), connector.getSSLVerifyClient()) && ObjectUtils.nullSafeEquals(this.getSSLVerifyDepth(), connector.getSSLVerifyDepth()) && super.equals(connector); }
From source file:org.wallride.service.PageService.java
@CacheEvict(value = WallRideCacheConfiguration.PAGE_CACHE, allEntries = true) public Page savePage(PageUpdateRequest request, AuthorizedUser authorizedUser) { postRepository.lock(request.getId()); Page page = pageRepository.findOneByIdAndLanguage(request.getId(), request.getLanguage()); LocalDateTime now = LocalDateTime.now(); String code = request.getCode(); if (code == null) { try {// w w w . j a v a2 s. c om code = new CodeFormatter().parse(request.getTitle(), LocaleContextHolder.getLocale()); } catch (ParseException e) { throw new ServiceException(e); } } if (!StringUtils.hasText(code)) { if (!page.getStatus().equals(Post.Status.DRAFT)) { throw new EmptyCodeException(); } } if (!page.getStatus().equals(Post.Status.DRAFT)) { Post duplicate = postRepository.findOneByCodeAndLanguage(code, request.getLanguage()); if (duplicate != null && !duplicate.equals(page)) { throw new DuplicateCodeException(code); } } if (!page.getStatus().equals(Post.Status.DRAFT)) { page.setCode(code); page.setDraftedCode(null); } else { page.setCode(null); page.setDraftedCode(code); } Page parent = (request.getParentId() != null) ? entityManager.getReference(Page.class, request.getParentId()) : null; if (!(page.getParent() == null && parent == null) && !ObjectUtils.nullSafeEquals(page.getParent(), parent)) { pageRepository.shiftLftRgt(page.getLft(), page.getRgt()); pageRepository.shiftRgt(page.getRgt()); pageRepository.shiftLft(page.getRgt()); int rgt = 0; if (parent == null) { rgt = pageRepository.findMaxRgt(); rgt++; } else { rgt = parent.getRgt(); pageRepository.unshiftRgt(rgt); pageRepository.unshiftLft(rgt); } page.setLft(rgt); page.setRgt(rgt + 1); } page.setParent(parent); Media cover = null; if (request.getCoverId() != null) { cover = entityManager.getReference(Media.class, request.getCoverId()); } page.setCover(cover); page.setTitle(request.getTitle()); page.setBody(request.getBody()); // User author = null; // if (request.getAuthorId() != null) { // author = entityManager.getReference(User.class, request.getAuthorId()); // } // page.setAuthor(author); LocalDateTime date = request.getDate(); if (Post.Status.PUBLISHED.equals(page.getStatus())) { if (date == null) { date = now.truncatedTo(ChronoUnit.HOURS); } else if (date.isAfter(now)) { page.setStatus(Post.Status.SCHEDULED); } } page.setDate(date); page.setLanguage(request.getLanguage()); page.getCategories().clear(); SortedSet<Category> categories = new TreeSet<>(); for (long categoryId : request.getCategoryIds()) { categories.add(entityManager.getReference(Category.class, categoryId)); } page.setCategories(categories); page.getTags().clear(); Set<String> tagNames = StringUtils.commaDelimitedListToSet(request.getTags()); if (!CollectionUtils.isEmpty(tagNames)) { for (String tagName : tagNames) { Tag tag = tagRepository.findOneForUpdateByNameAndLanguage(tagName, request.getLanguage()); if (tag == null) { tag = new Tag(); tag.setName(tagName); tag.setLanguage(request.getLanguage()); page.setCreatedAt(now); page.setCreatedBy(authorizedUser.toString()); page.setUpdatedAt(now); page.setUpdatedBy(authorizedUser.toString()); tag = tagRepository.saveAndFlush(tag); } page.getTags().add(tag); } } page.getRelatedPosts().clear(); Set<Post> relatedPosts = new HashSet<>(); for (long relatedId : request.getRelatedPostIds()) { relatedPosts.add(entityManager.getReference(Post.class, relatedId)); } page.setRelatedToPosts(relatedPosts); Seo seo = new Seo(); seo.setTitle(request.getSeoTitle()); seo.setDescription(request.getSeoDescription()); seo.setKeywords(request.getSeoKeywords()); page.setSeo(seo); List<Media> medias = new ArrayList<>(); if (StringUtils.hasText(request.getBody())) { // Blog blog = blogService.getBlogById(Blog.DEFAULT_ID); String mediaUrlPrefix = wallRideProperties.getMediaUrlPrefix(); Pattern mediaUrlPattern = Pattern.compile(String.format("%s([0-9a-zA-Z\\-]+)", mediaUrlPrefix)); Matcher mediaUrlMatcher = mediaUrlPattern.matcher(request.getBody()); while (mediaUrlMatcher.find()) { Media media = mediaRepository.findOneById(mediaUrlMatcher.group(1)); medias.add(media); } } page.setMedias(medias); page.setUpdatedAt(now); page.setUpdatedBy(authorizedUser.toString()); SortedSet<CustomFieldValue> fieldValues = new TreeSet<>(); Map<CustomField, CustomFieldValue> valueMap = new LinkedHashMap<>(); for (CustomFieldValue value : page.getCustomFieldValues()) { valueMap.put(value.getCustomField(), value); } page.getCustomFieldValues().clear(); if (!CollectionUtils.isEmpty(request.getCustomFieldValues())) { for (CustomFieldValueEditForm valueForm : request.getCustomFieldValues()) { CustomField customField = entityManager.getReference(CustomField.class, valueForm.getCustomFieldId()); CustomFieldValue value = valueMap.get(customField); if (value == null) { value = new CustomFieldValue(); } value.setCustomField(customField); value.setPost(page); if (valueForm.getFieldType().equals(CustomField.FieldType.CHECKBOX)) { if (!ArrayUtils.isEmpty(valueForm.getTextValues())) { value.setTextValue(String.join(",", valueForm.getTextValues())); } else { value.setTextValue(null); } } else { value.setTextValue(valueForm.getTextValue()); } value.setStringValue(valueForm.getStringValue()); value.setNumberValue(valueForm.getNumberValue()); value.setDateValue(valueForm.getDateValue()); value.setDatetimeValue(valueForm.getDatetimeValue()); if (!value.isEmpty()) { fieldValues.add(value); } } } page.setCustomFieldValues(fieldValues); return pageRepository.save(page); }
From source file:com.turbospaces.spaces.AbstractJSpace.java
private Object[] fetch0(final TransactionModificationContext modificationContext, final Object entry, final int timeout, final int maxResults, final int modifiers) { Preconditions.checkNotNull(entry);/*w w w. java 2s.c o m*/ Preconditions.checkArgument(maxResults >= 1, NON_POSITIVE_MAX_RESULTS); Preconditions.checkArgument(timeout >= 0, NEGATIVE_TIMEOUT); SpaceStore heapBuffer; CacheStoreEntryWrapper cacheStoreEntryWrapper; Object template; if (entry instanceof CacheStoreEntryWrapper) { cacheStoreEntryWrapper = (CacheStoreEntryWrapper) entry; heapBuffer = offHeapBuffers .get(cacheStoreEntryWrapper.getPersistentEntity().getOriginalPersistentEntity().getType()); template = cacheStoreEntryWrapper.getBean(); } else { heapBuffer = offHeapBuffers.get(entry.getClass()); cacheStoreEntryWrapper = CacheStoreEntryWrapper.writeValueOf(configuration.boFor(entry.getClass()), entry); template = entry; } boolean isTakeOnly = SpaceModifiers.isTakeOnly(modifiers); boolean isReadOnly = SpaceModifiers.isReadOnly(modifiers); boolean isEvictOnly = SpaceModifiers.isEvictOnly(modifiers); boolean isExclusiveRead = SpaceModifiers.isExclusiveRead(modifiers); boolean isMatchById = SpaceModifiers.isMatchById(modifiers); boolean isReturnAsBytes = SpaceModifiers.isReturnAsBytes(modifiers); if (isTakeOnly && isReadOnly) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to fetch by template %s with takeOnly and readOnly modifiers at the same time", template)); if (isTakeOnly && isEvictOnly) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to fetch by template %s with takeOnly and evictOnly modifiers at the same time", template)); if (isTakeOnly && isExclusiveRead) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to fetch by template %s with takeOnly and exclusiveReadLock modifiers at the same time", template)); if (isReadOnly && isEvictOnly) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to fetch by template %s with takeOnly and evictOnly modifiers at the same time", template)); if (isEvictOnly && isExclusiveRead) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to fetch by template %s with evictOnly and exclusiveReadLock modifiers at the same time", template)); if (isMatchById && cacheStoreEntryWrapper.getId() == null) throw new InvalidDataAccessApiUsageException(String.format( "Illegal attempt to perform matching by ID when id is not provided. Template = %s", template)); if (logger.isDebugEnabled()) logger.debug( "onFetch: template={}, id={}, version={}, routing={}, timeout={}, maxResults={}, transaction={}", new Object[] { cacheStoreEntryWrapper.getBean(), cacheStoreEntryWrapper.getId(), cacheStoreEntryWrapper.getOptimisticLockVersion(), cacheStoreEntryWrapper.getRouting(), timeout, maxResults, modificationContext.getTransactionId() }); // fetch ByteBuffer[] c = heapBuffer.fetch(cacheStoreEntryWrapper, modificationContext, timeout, maxResults, modifiers); if (c != null) if (!isReturnAsBytes) { int size = c.length; Class type = cacheStoreEntryWrapper.getPersistentEntity().getOriginalPersistentEntity().getType(); Object[] result = new Object[size]; Map<EntryKeyLockQuard, WriteTakeEntry> takes = modificationContext.getTakes(); for (int i = 0; i < size; i++) { SerializationEntry sEntry = configuration.getKryo().deserialize(c[i], type); Object[] propertyValues = sEntry.getPropertyValues(); Object id = propertyValues[BO.getIdIndex()]; if (!takes.isEmpty()) for (Entry<EntryKeyLockQuard, WriteTakeEntry> next : takes.entrySet()) if (ObjectUtils.nullSafeEquals(next.getKey().getKey(), id)) { next.getValue().setObj(sEntry.getObject()); next.getValue().setPropertyValues(propertyValues); } result[i] = sEntry.getObject(); } return result; } return c; }
From source file:com.wavemaker.tools.io.virtual.VirtualResourceStore.java
@Override public boolean equals(Object obj) { if (obj == this) { return true; }/*from ww w. j av a 2 s . com*/ if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } VirtualResourceStore other = (VirtualResourceStore) obj; boolean rtn = true; rtn &= ObjectUtils.nullSafeEquals(getRoot(), other.getRoot()); rtn &= ObjectUtils.nullSafeEquals(getPath().getUnjailedPath(), other.getPath().getUnjailedPath()); return rtn; }
From source file:org.cloudfoundry.identity.uaa.oauth.UaaAuthorizationEndpoint.java
private boolean isAuthorizationRequestModified(AuthorizationRequest authorizationRequest, Map<String, Object> originalAuthorizationRequest) { if (!ObjectUtils.nullSafeEquals(authorizationRequest.getClientId(), originalAuthorizationRequest.get(OAuth2Utils.CLIENT_ID))) { return true; }//from w w w . jav a 2s . co m if (!ObjectUtils.nullSafeEquals(authorizationRequest.getState(), originalAuthorizationRequest.get(OAuth2Utils.STATE))) { return true; } if (!ObjectUtils.nullSafeEquals(authorizationRequest.getRedirectUri(), originalAuthorizationRequest.get(OAuth2Utils.REDIRECT_URI))) { return true; } if (!ObjectUtils.nullSafeEquals(authorizationRequest.getResponseTypes(), originalAuthorizationRequest.get(OAuth2Utils.RESPONSE_TYPE))) { return true; } if (!ObjectUtils.nullSafeEquals(authorizationRequest.isApproved(), originalAuthorizationRequest.get("approved"))) { return true; } if (!ObjectUtils.nullSafeEquals(authorizationRequest.getResourceIds(), originalAuthorizationRequest.get("resourceIds"))) { return true; } if (!ObjectUtils.nullSafeEquals(authorizationRequest.getAuthorities(), originalAuthorizationRequest.get("authorities"))) { return true; } return !ObjectUtils.nullSafeEquals(authorizationRequest.getScope(), originalAuthorizationRequest.get(OAuth2Utils.SCOPE)); }
From source file:org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceDynamicInterceptor.java
public boolean equals(Object other) { if (this == other) return true; if (other instanceof ServiceDynamicInterceptor) { ServiceDynamicInterceptor oth = (ServiceDynamicInterceptor) other; return (mandatoryService == oth.mandatoryService && ObjectUtils.nullSafeEquals(holder, oth.holder) && ObjectUtils.nullSafeEquals(filter, oth.filter) && ObjectUtils.nullSafeEquals(retryTemplate, oth.retryTemplate)); } else//from w w w .j a v a 2 s. co m return false; }
From source file:org.grails.beans.support.CachedIntrospectionResults.java
/** * Compare the given {@code PropertyDescriptors} and return {@code true} if * they are equivalent, i.e. their read method, write method, property type, * property editor and flags are equivalent. * @see java.beans.PropertyDescriptor#equals(Object) *//*w w w . java2 s.co m*/ public static boolean equals(PropertyDescriptor pd, PropertyDescriptor otherPd) { return (ObjectUtils.nullSafeEquals(pd.getReadMethod(), otherPd.getReadMethod()) && ObjectUtils.nullSafeEquals(pd.getWriteMethod(), otherPd.getWriteMethod()) && ObjectUtils.nullSafeEquals(pd.getPropertyType(), otherPd.getPropertyType()) && ObjectUtils.nullSafeEquals(pd.getPropertyEditorClass(), otherPd.getPropertyEditorClass()) && pd.isBound() == otherPd.isBound() && pd.isConstrained() == otherPd.isConstrained()); }
From source file:org.kuali.kfs.fp.businessobject.CheckBase.java
/** * @see org.kuali.kfs.fp.businessobject.Check#isLike(org.kuali.kfs.fp.businessobject.Check) *//*from ww w . j a v a2s . c om*/ @Override public boolean isLike(Check other) { boolean like = false; if (StringUtils.equals(checkNumber, other.getCheckNumber())) { if (StringUtils.equals(description, other.getDescription())) { if (StringUtils.equals(financialDocumentTypeCode, other.getFinancialDocumentTypeCode()) && StringUtils.equals(cashieringStatus, other.getCashieringStatus())) { if (StringUtils.equals(documentNumber, other.getDocumentNumber())) { if (ObjectUtils.nullSafeEquals(sequenceId, other.getSequenceId())) { if (ObjectUtils.nullSafeEquals(financialDocumentDepositLineNumber, other.getFinancialDocumentDepositLineNumber())) { if (DateUtils.isSameDay(checkDate, other.getCheckDate())) { if ((amount != null) && amount.equals(other.getAmount())) { like = true; } } } } } } } } return like; }