public Violation checkInstantiation ( Collection < TypeVariableSymbol > typeParameters , Collection < Type > typeArguments ) { return Streams . zip ( typeParameters . stream ( ) , typeArguments . stream ( ) , ( sym , type ) -> { if ( ! hasThreadSafeTypeParameterAnnotation ( sym ) ) { return Violation . absent ( ) ; } Violation info = isThreadSafeType ( /* allowContainerTypeParameters= */ true , /* containerTypeParameters= */ ImmutableSet . of ( ) , type ) ; if ( ! info . isPresent ( ) ) { return Violation . absent ( ) ; } return info . plus ( String . format ( "instantiation of '%s' is %s" , sym , purpose . mutableOrNotThreadSafe ( ) ) ) ; } ) . filter ( Violation :: isPresent ) . findFirst ( ) . orElse ( Violation . absent ( ) ) ; }
Checks that any thread - safe type parameters are instantiated with thread - safe types .