public Class<?> mainType() { return first( types ); }
@Override public T importService( final ImportedServiceDescriptor serviceDescriptor ) throws ServiceImporterException { T instance = null; Iterable<MetaInfoHolder> holders = Iterables.iterable( serviceDescriptor, module, layer, application ); for( final MetaInfoHolder metaInfoHolder : holders ) { Function<Class<?>, T> metaFinder = new Function<Class<?>, T>() { @Override @SuppressWarnings( "unchecked" ) public T map( Class<?> type ) { return (T) metaInfoHolder.metaInfo( type ); } }; instance = first( filter( notNull(), map( metaFinder, serviceDescriptor.types() ) ) ); if( instance != null ) { break; } } return instance; }
public static Iterable<DomainEventValue> events( Iterable<UnitOfWorkDomainEventsValue> transactions ) { return Iterables.flattenIterables( Iterables.map( new Function<UnitOfWorkDomainEventsValue, Iterable<DomainEventValue>>() { @Override public Iterable<DomainEventValue> map( UnitOfWorkDomainEventsValue unitOfWorkDomainEventsValue ) { return unitOfWorkDomainEventsValue.events().get(); } }, transactions ) ); }
public static Iterable<Annotation> findAccessorAndTypeAnnotationsIn( AccessibleObject accessor ) { return flatten( iterable( accessor.getAnnotations() ), flattenIterables( map( Annotations.ANNOTATIONS_OF, interfacesOf( typeOf( accessor ) ) ) ) ); } }
for( Annotation[] annotations : method.getParameterAnnotations() ) Name name = (Name) first( filter( isType( Name.class ), iterable( annotations ) ) ); if( arg == null && !matchesAny( isType( Optional.class ), iterable( annotations ) ) )
public static Specification<ApplicationEvent> withNames( final Class eventClass ) { return ApplicationEvents.withNames( Iterables.map( new Function<Method, String>() { @Override public String map( Method method ) { return method.getName(); } }, Iterables.toList( Methods.METHODS_OF.map( eventClass ) ) )); }
@Override @SuppressWarnings( {"raw", "unchecked"} ) public Iterable<Class<?>> map( Type type ) { if( type == null ) { return empty(); } if( type.equals( Object.class ) ) { Class<?> aClass = (Class<?>) type; return cast( iterable( aClass ) ); } else { type = RAW_CLASS.map( type ); Class superclass = ( (Class) type ).getSuperclass(); return prepend( (Class<?>) type, map( superclass ) ); } } };
@Override public Iterable<Field> map( Class<?> type ) { return iterable( type.getDeclaredFields() ); } } );
@Override public <T> Iterable<T> convert( final Class<T> valueType, Iterable<Object> entities ) { return Iterables.map( new Function<Object, T>() { @Override public T map( Object entity ) { return convert( valueType, entity ); } }, entities ); }
@Override public String toString() { return collectionProperty + " contains " + Iterables.toList( valueCollection ); } }
@Override public Query filter( Specification<T> filter ) { iterable = Iterables.filter( filter, iterable ); return this; }
@Override public boolean satisfiedBy( ModelDescriptor item ) { return matchesAny( new Specification<String>() { @Override public boolean satisfiedBy( String item ) { return item.equals( className ); } }, map( new Function<Class<?>, String>() { @Override public String map( Class<?> item ) { return item.getName(); } }, item.types() ) ); } };