private static IConstructorInfo callableConstructorImpl( List<? extends IConstructorInfo> constructors, boolean strict, IType... params ) { Map<IConstructorType, IConstructorInfo> cis = new HashMap<IConstructorType, IConstructorInfo>(); params = params == null ? EMPTY_TYPES : params; for( IConstructorInfo constructorInfo : constructors ) { if( params.length == constructorInfo.getParameters().length ) { cis.put( GosuShop.getConstructorInfoFactory().makeConstructorType( constructorInfo ), constructorInfo ); } } List<MethodScore> list = MethodScorer.instance().scoreMethods( new ArrayList<IInvocableType>( cis.keySet() ), Arrays.asList( params ) ); if( list.size() == 0 ) { return null; } else if( list.size() > 1 && list.get( 0 ).getScore() == list.get( 1 ).getScore() ) { throw new IllegalArgumentException( "Ambiguous constructors: There is more than one constructor that accepts args " + Arrays.asList( params ) ); } IInvocableType rawFunctionType = list.get( 0 ).getRawFunctionType(); if( strict && !areParamsCompatible( rawFunctionType.getParameterTypes(), params ) ) { return null; } return cis.get( rawFunctionType ); }
if( strict && !areParamsCompatible( rawFunctionType.getParameterTypes(), params ) )
private static IConstructorInfo callableConstructorImpl( List<? extends IConstructorInfo> constructors, boolean strict, IType... params ) { Map<IConstructorType, IConstructorInfo> cis = new HashMap<IConstructorType, IConstructorInfo>(); params = params == null ? EMPTY_TYPES : params; for( IConstructorInfo constructorInfo : constructors ) { if( params.length == constructorInfo.getParameters().length ) { cis.put( GosuShop.getConstructorInfoFactory().makeConstructorType( constructorInfo ), constructorInfo ); } } List<MethodScore> list = scoreMethods( new ArrayList<IInvocableType>( cis.keySet() ), Arrays.asList( params ), Collections.EMPTY_LIST ); if( list.size() == 0 ) { return null; } else if( list.size() > 1 && list.get( 0 ).getScore() == list.get( 1 ).getScore() ) { throw new IllegalArgumentException( "Ambiguous constructors: There is more than one constructor that accepts args " + Arrays.asList( params ) ); } IInvocableType rawFunctionType = list.get( 0 ).getRawFunctionType(); if( strict && !areParamsCompatible( rawFunctionType.getParameterTypes(), params ) ) { return null; } return cis.get( rawFunctionType ); }
if( strict && !areParamsCompatible( rawFunctionType.getParameterTypes(), params ) )