Java Code Examples for java.io.Serializable#equals()
The following examples show how to use
java.io.Serializable#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Client.java From qpid-broker-j with Apache License 2.0 | 6 votes |
private void receiveReply(final MessageConsumer consumer, final Serializable expectedCorrelationId) throws Exception { final Message message = consumer.receive(RECEIVE_TIMEOUT); System.out.println(String.format("Received message: %s", message)); if (expectedCorrelationId != null) { if (expectedCorrelationId instanceof byte[]) { if (!Arrays.equals((byte[]) expectedCorrelationId, message.getJMSCorrelationIDAsBytes())) { throw new VerificationException("ReplyTo message has unexpected correlationId."); } } else { if (!expectedCorrelationId.equals(message.getJMSCorrelationID())) { throw new VerificationException("ReplyTo message has unexpected correlationId."); } } } }
Example 2
Source File: ElderTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private boolean identifyElder() { SharedMap map = DLockBlackboard.getInstance().getSharedMap(); DistributedSystem system = getDistributedSystem(); DM dm = ((InternalDistributedSystem)system).getDistributionManager(); Serializable whoIThinkElderIs = dm.getElderId(); log().info("ElderID is: " + whoIThinkElderIs); Assert.assertTrue(whoIThinkElderIs != null, "null elder"); boolean elderIsMe = whoIThinkElderIs.equals(dm.getId()); if (elderIsMe) { log().info("Elder identified: " + RemoteTestModule.getMyClientName()); log().info("ElderID is: " + whoIThinkElderIs); map.put(ELDER_ID, whoIThinkElderIs); map.put(ELDER_CLIENT_NAME, RemoteTestModule.getMyClientName()); return true; } else { return false; } }
Example 3
Source File: ElderTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private boolean identifyElder() { SharedMap map = DLockBlackboard.getInstance().getSharedMap(); DistributedSystem system = getDistributedSystem(); DM dm = ((InternalDistributedSystem)system).getDistributionManager(); Serializable whoIThinkElderIs = dm.getElderId(); log().info("ElderID is: " + whoIThinkElderIs); Assert.assertTrue(whoIThinkElderIs != null, "null elder"); boolean elderIsMe = whoIThinkElderIs.equals(dm.getId()); if (elderIsMe) { log().info("Elder identified: " + RemoteTestModule.getMyClientName()); log().info("ElderID is: " + whoIThinkElderIs); map.put(ELDER_ID, whoIThinkElderIs); map.put(ELDER_CLIENT_NAME, RemoteTestModule.getMyClientName()); return true; } else { return false; } }
Example 4
Source File: XStreamSavingConverter.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
protected void registerEntityMapping(final Class< ? > entityClass, final Serializable oldId, final Serializable newId) { final Serializable registeredNewId = getNewId(entityClass, oldId); if (registeredNewId != null && registeredNewId.equals(newId) == false) { log.error("Oups, double entity mapping found for entity '" + entityClass + "' with old id=" + oldId + " . New id " + newId + " ignored, using previous stored id " + registeredNewId + " instead."); } else { this.entityMapping.put(getClassname4History(entityClass) + oldId, newId); } }
Example 5
Source File: ContentPropertyRestrictionInterceptor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private boolean isContentChanged(NodeRef nodeRef, QName qname, Serializable newValue) { Serializable existingValue = internalNodeService.getProperty(nodeRef, qname); if (existingValue == null) { return newValue != null; } else { if (newValue instanceof ContentData && existingValue instanceof ContentData) { // ContentData may be changed in mimetype, locale, size or encoding String existingUrl = ((ContentData) existingValue).getContentUrl(); String newUrl = ((ContentData) newValue).getContentUrl(); return !Objects.equals(existingUrl, newUrl); } else { return !existingValue.equals(newValue); } } }
Example 6
Source File: JPAPerister.java From statefulj with Apache License 2.0 | 6 votes |
/** * @param stateful * @param current * @param next * @throws NoSuchFieldException * @throws IllegalAccessException * @throws StaleStateException */ private void updateStateInMemory(T stateful, State<T> current, State<T> next) throws NoSuchFieldException, IllegalAccessException, StaleStateException { // The Entity hasn't been persisted to the database - so it exists only // this Application memory. So, serialize the qualified update to prevent // concurrency conflicts // synchronized(stateful) { Serializable state = this.getState(stateful); state = (state == null) ? getStartState().getName() : state; if (state.equals(current.getName())) { setState(stateful, next.getName()); } else { throwStaleState(current, next); } } }
Example 7
Source File: JoinBoltTest.java From bullet-storm with Apache License 2.0 | 5 votes |
private static boolean isSameMetadata(Object actual, Object expected) { Metadata actualMetadata = (Metadata) actual; Metadata expectedMetadata = (Metadata) expected; if (actualMetadata.getSignal() != expectedMetadata.getSignal()) { return false; } Serializable actualContent = actualMetadata.getContent(); Serializable expectedContent = expectedMetadata.getContent(); return actualContent == expectedContent || actualContent.equals(expectedContent); }
Example 8
Source File: TerminalSession.java From JobX with Apache License 2.0 | 5 votes |
public static List<TerminalClient> findClient(Serializable sessionId) throws IOException { List<TerminalClient> terminalClients = new ArrayList<TerminalClient>(0); if (notEmpty(terminalSession)) { for (Map.Entry<WebSocketSession, TerminalClient> entry : terminalSession.entrySet()) { TerminalClient terminalClient = entry.getValue(); if (terminalClient != null && terminalClient.getTerminal() != null) { if (sessionId.equals(terminalClient.getHttpSessionId())) { terminalClients.add(terminalClient); } } } } return terminalClients; }
Example 9
Source File: AbstractMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected void onConfigure() { super.onConfigure(); C critery = getPropertyObject(); Serializable newSignature = getSignature(critery); if(!newSignature.equals(stateSignature) || get(PANEL_ID)==null) { stateSignature = newSignature; component = resolveComponent(PANEL_ID, critery); onPostResolveComponent(component, critery); // component.setOutputMarkupId(true); addOrReplace(component); } }
Example 10
Source File: ProxyVisitor.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Has the owner of the collection changed since the collection * was snapshotted and detached? */ protected static boolean isOwnerUnchanged( final PersistentCollection snapshot, final CollectionPersister persister, final Serializable id ) { return isCollectionSnapshotValid(snapshot) && persister.getRole().equals( snapshot.getRole() ) && id.equals( snapshot.getKey() ); }
Example 11
Source File: EventGenerationBehaviours.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private Map<String, Property> getChanges(Map<QName, Serializable> before, Map<QName, Serializable> after) { Map<String, Property> ret = new HashMap<String, Property>(); Set<QName> intersect = new HashSet<QName>(before.keySet()); intersect.retainAll(after.keySet()); for(QName propQName : intersect) { Serializable valueBefore = before.get(propQName); Serializable valueAfter = after.get(propQName); Serializable value = null; if(valueBefore == null && valueAfter == null) { continue; } else if(valueBefore == null && valueAfter != null) { value = valueAfter; } else if(valueBefore != null && valueAfter == null) { value = valueAfter; } else if(!valueBefore.equals(valueAfter)) { value = valueAfter; } DataType type = getPropertyType(propQName); String propName = propQName.toPrefixString(namespaceService); Property property = new Property(propName, value, type); ret.put(propName, property); } return ret; }
Example 12
Source File: Configuration.java From jace with GNU General Public License v2.0 | 5 votes |
public void setFieldValue(String field, Serializable value) { if (value != null) { if (value.equals(getFieldValue(field))) { return; } } else { if (getFieldValue(field) == null) { setChanged(false); return; } } setChanged(true); setRawFieldValue(field, value); }
Example 13
Source File: WorkflowPackageImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Extend(traitAPI=WorkflowPackageTrait.class,extensionAPI=WorkflowPackageExtension.class) public boolean setWorkflowForPackage(WorkflowInstance instance) { NodeRef packageNode = instance.getWorkflowPackage(); if(packageNode==null) return false; Serializable pckgInstanceId = nodeService.getProperty(packageNode, WorkflowModel.PROP_WORKFLOW_INSTANCE_ID); if(pckgInstanceId != null) { if(pckgInstanceId.equals(instance.getId())) { return false; } String msg = messageService.getMessage(ERR_PACKAGE_ALREADY_ASSOCIATED, packageNode, instance.getId(), pckgInstanceId); throw new WorkflowException(msg); } if (nodeService.hasAspect(packageNode, WorkflowModel.ASPECT_WORKFLOW_PACKAGE)==false) { createPackage(packageNode); } String definitionId = instance.getDefinition().getId(); String definitionName = instance.getDefinition().getName(); String instanceId = instance.getId(); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_ID, definitionId); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_NAME, definitionName); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_INSTANCE_ID, instanceId); return true; }
Example 14
Source File: WebComponentBinding.java From flow with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") void updateValue(Serializable newValue) { if (isReadOnly()) { LoggerFactory.getLogger(getClass()) .warn(String.format("An attempt was made to write to " + "a read-only property '%s' owned by exported " + "component %s", getName(), getType().getCanonicalName())); return; } if (newValue != null && !getType().isAssignableFrom(newValue.getClass())) { throw new IllegalArgumentException(String.format("Parameter " + "'newValue' is of the wrong type: onChangeHandler" + " of the property expected to receive %s but " + "found %s instead.", getType().getCanonicalName(), newValue.getClass().getCanonicalName())); } P newTypedValue = (P) newValue; // null values are always set to default value (which might still be // null for some types) if (newTypedValue == null) { newTypedValue = data.getDefaultValue(); } boolean updated = false; if (this.value != null && !this.value.equals(newTypedValue)) { updated = true; } else if (newValue != null && !newValue.equals(this.value)) { updated = true; } if (updated) { this.value = newTypedValue; notifyValueChange(); } }
Example 15
Source File: GanttChartData.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public GanttTask getExternalObject(final Serializable id) { if (id == null || externalObjects == null) { return null; } for (final GanttTask task : externalObjects) { if (id.equals(task.getId()) == true) { return task; } } return null; }
Example 16
Source File: AbstractResource.java From hellosign-java-sdk with MIT License | 4 votes |
protected <T> List<T> getList(Class<T> clazz, String key, Serializable filterValue, String filterColumnName) { List<T> returnList = new ArrayList<>(); if (dataObj.has(key)) { try { JSONArray array = dataObj.getJSONArray(key); if (array.length() == 0) { return returnList; } Constructor<?> constructor = getConstructor(clazz, array.get(0).getClass()); if (constructor == null) { return returnList; } for (int i = 0; i < array.length(); i++) { Object obj = array.get(i); // Suppress the warning for the cast, since we checked in // getConstructor() @SuppressWarnings("unchecked") T newItem = (T) constructor.newInstance(obj); if (filterColumnName == null && filterValue == null) { // If we have no filter, add the item returnList.add(newItem); } else if (filterColumnName != null && filterValue != null) { // If we have a filter, test for column and value if (obj instanceof JSONObject) { JSONObject testObj = (JSONObject) obj; if (testObj.has(filterColumnName)) { Object columnObj = testObj.get(filterColumnName); if (filterValue.equals(columnObj)) { returnList.add(newItem); } } } } else if (filterValue instanceof String && newItem instanceof String) { // If we have a filter value, but no column name, // test for String equality if (filterValue.equals(newItem)) { returnList.add(newItem); } } } } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } } return returnList; }
Example 17
Source File: IdentifierValue.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Does the given identifier belong to a new instance? */ public Boolean isUnsaved(Serializable id) { if ( log.isTraceEnabled() ) log.trace("id unsaved-value: " + value); return id==null || id.equals(value) ? Boolean.TRUE : Boolean.FALSE; }
Example 18
Source File: CollectionCacheInvalidator.java From lams with GNU General Public License v2.0 | 4 votes |
private void evictCache(Object entity, EntityPersister persister, EventSource session, Object[] oldState) { try { SessionFactoryImplementor factory = persister.getFactory(); Set<String> collectionRoles = factory.getMetamodel().getCollectionRolesByEntityParticipant( persister.getEntityName() ); if ( collectionRoles == null || collectionRoles.isEmpty() ) { return; } for ( String role : collectionRoles ) { final CollectionPersister collectionPersister = factory.getMetamodel().collectionPersister( role ); if ( !collectionPersister.hasCache() ) { // ignore collection if no caching is used continue; } // this is the property this OneToMany relation is mapped by String mappedBy = collectionPersister.getMappedByProperty(); if ( !collectionPersister.isManyToMany() && mappedBy != null && !mappedBy.isEmpty() ) { int i = persister.getEntityMetamodel().getPropertyIndex( mappedBy ); Serializable oldId = null; if ( oldState != null ) { // in case of updating an entity we perhaps have to decache 2 entity collections, this is the // old one oldId = getIdentifier( session, oldState[i] ); } Object ref = persister.getPropertyValue( entity, i ); Serializable id = getIdentifier( session, ref ); // only evict if the related entity has changed if ( ( id != null && !id.equals( oldId ) ) || ( oldId != null && !oldId.equals( id ) ) ) { if ( id != null ) { evict( id, collectionPersister, session ); } if ( oldId != null ) { evict( oldId, collectionPersister, session ); } } } else { LOG.debug( "Evict CollectionRegion " + role ); final SoftLock softLock = collectionPersister.getCacheAccessStrategy().lockRegion(); session.getActionQueue().registerProcess( (success, session1) -> { collectionPersister.getCacheAccessStrategy().unlockRegion( softLock ); } ); } } } catch ( Exception e ) { if ( PROPAGATE_EXCEPTION ) { throw new IllegalStateException( e ); } // don't let decaching influence other logic LOG.error( "", e ); } }
Example 19
Source File: DbNodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private NodeRef restoreNodeImpl(NodeRef archivedNodeRef, NodeRef destinationParentNodeRef, QName assocTypeQName, QName assocQName) { Pair<Long, NodeRef> archivedNodePair = getNodePairNotNull(archivedNodeRef); Long archivedNodeId = archivedNodePair.getFirst(); Set<QName> existingAspects = nodeDAO.getNodeAspects(archivedNodeId); Set<QName> newAspects = new HashSet<QName>(5); Map<QName, Serializable> existingProperties = nodeDAO.getNodeProperties(archivedNodeId); Map<QName, Serializable> newProperties = new HashMap<QName, Serializable>(11); // the node must be a top-level archive node if (!existingAspects.contains(ContentModel.ASPECT_ARCHIVED)) { throw new AlfrescoRuntimeException("The node to restore is not an archive node"); } // Remove the secondary link to the user that deleted the node List<ChildAssociationRef> parentAssocsToRemove = getParentAssocs( archivedNodeRef, ContentModel.ASSOC_ARCHIVED_LINK, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef parentAssocToRemove : parentAssocsToRemove) { this.removeSecondaryChildAssociation(parentAssocToRemove); } ChildAssociationRef originalPrimaryParentAssocRef = (ChildAssociationRef) existingProperties.get( ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); Serializable originalOwner = existingProperties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_OWNER); // remove the archived aspect Set<QName> removePropertyQNames = new HashSet<QName>(11); Set<QName> removeAspectQNames = new HashSet<QName>(3); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_BY); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_DATE); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_ORIGINAL_OWNER); removeAspectQNames.add(ContentModel.ASPECT_ARCHIVED); // restore the original ownership if (originalOwner == null || originalOwner.equals(OwnableService.NO_OWNER)) { // The ownable aspect was not present before removeAspectQNames.add(ContentModel.ASPECT_OWNABLE); removePropertyQNames.add(ContentModel.PROP_OWNER); } else { newAspects.add(ContentModel.ASPECT_OWNABLE); newProperties.put(ContentModel.PROP_OWNER, originalOwner); } // Prepare the node for restoration: remove old aspects and properties; add new aspects and properties nodeDAO.removeNodeProperties(archivedNodeId, removePropertyQNames); nodeDAO.removeNodeAspects(archivedNodeId, removeAspectQNames); nodeDAO.addNodeProperties(archivedNodeId, newProperties); nodeDAO.addNodeAspects(archivedNodeId, newAspects); if (destinationParentNodeRef == null) { // we must restore to the original location destinationParentNodeRef = originalPrimaryParentAssocRef.getParentRef(); } // check the associations if (assocTypeQName == null) { assocTypeQName = originalPrimaryParentAssocRef.getTypeQName(); } if (assocQName == null) { assocQName = originalPrimaryParentAssocRef.getQName(); } // move the node to the target parent, which may or may not be the original parent ChildAssociationRef newChildAssocRef = moveNode( archivedNodeRef, destinationParentNodeRef, assocTypeQName, assocQName); // the node reference has changed due to the store move NodeRef restoredNodeRef = newChildAssocRef.getChildRef(); invokeOnRestoreNode(newChildAssocRef); // done if (logger.isDebugEnabled()) { logger.debug("Restored node: \n" + " original noderef: " + archivedNodeRef + "\n" + " restored noderef: " + restoredNodeRef + "\n" + " new parent: " + destinationParentNodeRef); } return restoredNodeRef; }
Example 20
Source File: Node2ServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * {@inheritDoc} * <p> * * Implementation for version store v2 */ @Override public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue) { // If lightWeightVersionStore call default version store implementation. if (sourceRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID)) { return super.getTargetAssocsByPropertyValue(sourceRef, qnamePattern, propertyQName, propertyValue); } // Get the assoc references from the version store. List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs(VersionUtil.convertNodeRef(sourceRef), Version2Model.CHILD_QNAME_VERSIONED_ASSOCS, qnamePattern); List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { // Get the assoc reference. NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef) this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode)) { Long assocDbId = (Long) this.dbNodeService.getProperty(childRef, Version2Model.PROP_QNAME_ASSOC_DBID); // Check if property type validation has to be done. if (propertyQName != null) { Serializable propertyValueRetrieved = this.dbNodeService.getProperty(referencedNode, propertyQName); // Check if property value has been retrieved (property // exists) and is equal to the requested value. if (propertyValueRetrieved == null || !propertyValueRetrieved.equals(propertyValue)) { continue; } } // Build an assoc ref to add to the returned list. AssociationRef newAssocRef = new AssociationRef(assocDbId, sourceRef, childAssocRef.getQName(), referencedNode); result.add(newAssocRef); } } return result; }