@Override public boolean satisfiedBy( Composite item ) { return Specifications.not( operand ).satisfiedBy( item ); }
public static <T> T firstService( Specification<ServiceReference<?>> qualifier, Iterable<ServiceReference<T>> services ) { for( ServiceReference<T> service : services ) { if( qualifier.satisfiedBy( service ) ) { return service.get(); } } return null; }
@Override public void receive( UnitOfWorkDomainEventsValue item ) throws T { for( Map.Entry<Specification<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> specificationReceiverEntry : routes.entrySet() ) { if (specificationReceiverEntry.getKey().satisfiedBy( item )) { specificationReceiverEntry.getValue().receive( item ); return; } } // No match, use default defaultReceiver.receive( item ); } });
@Override public void receive( DomainEventValue item ) throws T { for( Map.Entry<Specification<DomainEventValue>, Receiver<DomainEventValue, T>> specificationReceiverEntry : routeEvent.entrySet() ) { if( specificationReceiverEntry.getKey().satisfiedBy( item ) ) { specificationReceiverEntry.getValue().receive( item ); return; } } // No match, use default defaultReceiver.receive( item ); } } );
if( STRING_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) else if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) else if( STRING_MAP_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) )
if( STRING_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) else if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) ) else if( STRING_MAP_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) )
@Override public EntityReference map( AssociationDescriptor eAssocDesc ) { try { return EntityReference.entityReferenceFor( vState.associationFor( eAssocDesc.accessor() ) ); } catch( IllegalArgumentException assocNotFoundOnValue ) { // Find String Property and convert to Association String propName = eAssocDesc.qualifiedName().name(); try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) { String assocState = (String) vState.propertyFor( vPropDesc.accessor() ).get(); return EntityReference.parseEntityReference( assocState ); } return null; } catch( IllegalArgumentException propNotFoundOnValue ) { return null; } } } };
@Override public Map<String, EntityReference> map( AssociationDescriptor eAssocDesc ) { try { NamedAssociation<?> vAssocState = vState.namedAssociationFor( eAssocDesc.accessor() ); return NAMED_ASSOC_TO_ENTITY_REF_MAP.map( vAssocState ); } catch( IllegalArgumentException assocNotFoundOnValue ) { // Find Map<String,String> Property and convert to NamedAssociation String propName = eAssocDesc.qualifiedName().name(); try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) { Map<String, String> vAssocState = (Map) vState .propertyFor( vPropDesc.accessor() ).get(); return STRING_MAP_TO_ENTITY_REF_MAP.map( vAssocState ); } return Collections.EMPTY_MAP; } catch( IllegalArgumentException propNotFoundOnValue ) { return Collections.EMPTY_MAP; } } } };
@Override public Iterable<EntityReference> map( AssociationDescriptor eAssocDesc ) { try { ManyAssociation<Object> vAssocState = vState.manyAssociationFor( eAssocDesc.accessor() ); return MANY_ASSOC_TO_ENTITY_REF_ITERABLE.map( vAssocState ); } catch( IllegalArgumentException assocNotFoundOnValue ) { // Find Collection<String> Property and convert to ManyAssociation String propName = eAssocDesc.qualifiedName().name(); try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) { Collection<String> vAssocState = (Collection) vState .propertyFor( vPropDesc.accessor() ).get(); return STRING_COLLEC_TO_ENTITY_REF_ITERABLE.map( vAssocState ); } return Iterables.empty(); } catch( IllegalArgumentException propNotFoundOnValue ) { return Iterables.empty(); } } } };
if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) )
@Override public EntityReference map( AssociationDescriptor eAssocDesc ) { String assocName = eAssocDesc.qualifiedName().name(); try { AssociationDescriptor vAssocDesc = vStateDesc.getAssociationByName( assocName ); Object assocEntity = vState.associationFor( vAssocDesc.accessor() ).get(); return assocEntity == null ? null : EntityReference.entityReferenceFor( assocEntity ); } catch( IllegalArgumentException assocNotFoundOnValue ) { // Association not found on Value, find Property<String> and convert to Association try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName ); if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) { String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get(); return assocId == null ? null : EntityReference.parseEntityReference( assocId ); } return null; } catch( IllegalArgumentException propNotFoundOnValue ) { return null; } } } };
if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) )
if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) )
if( STRING_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) if( STRING_COLLECTION_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) ) if( STRING_MAP_TYPE_SPEC.satisfiedBy( vPropDesc.valueType() ) )