public static ImmutableMap < String , PrimitiveData > convertCompileTimeGlobalsMap ( Map < String , ? > compileTimeGlobalsMap ) { ImmutableMap . Builder < String , PrimitiveData > resultMapBuilder = ImmutableMap . builder ( ) ; for ( Map . Entry < String , ? > entry : compileTimeGlobalsMap . entrySet ( ) ) { Object valueObj = entry . getValue ( ) ; PrimitiveData value ; boolean isValidValue = true ; try { SoyValue value0 = SoyValueConverter . INSTANCE . convert ( valueObj ) . resolve ( ) ; if ( ! ( value0 instanceof PrimitiveData ) ) { isValidValue = false ; } value = ( PrimitiveData ) value0 ; } catch ( SoyDataException sde ) { isValidValue = false ; value = null ; // make compiler happy } if ( ! isValidValue ) { throw new IllegalArgumentException ( "Compile-time globals map contains invalid value: " + valueObj + " for key: " + entry . getKey ( ) ) ; } resultMapBuilder . put ( entry . getKey ( ) , value ) ; } return resultMapBuilder . build ( ) ; }
Converts a compile - time globals map in user - provided format into one in the internal format .