public < T > DefaultOverride < T > override ( final T proxiedMethodCall ) { final MethodIdProxyFactory . MethodAndScope lastProxyMethodAndScope = MethodIdProxyFactory . getLastIdentifiedMethodAndScope ( ) ; if ( lastProxyMethodAndScope == null ) { throw new ConfigException ( "Failed to identify config method previous to calling overrideDefault" ) ; } if ( ! lastProxyMethodAndScope . getScopeOpt ( ) . equals ( scopeNameOpt ) ) { throw new ConfigException ( "Identified config method is not using proxy for the same scope name. Scope expected: {}, from last proxy call: {}" , scopeNameOpt , lastProxyMethodAndScope . getScopeOpt ( ) ) ; } final ConfigDescriptor desc = ConfigSystem . descriptorFactory . buildDescriptor ( lastProxyMethodAndScope . getMethod ( ) , scopeNameOpt ) ; final PropertyIdentifier propertyId = ConfigSystem . getIdentifier ( desc ) ; return value -> { // Override Binding of ConstantValuePropertyAccessor ConstantValuePropertyAccessor cvProp = ConstantValuePropertyAccessor . fromRawValue ( value ) ; OverrideModule . this . bind ( ConstantValuePropertyAccessor . class ) . annotatedWith ( propertyId ) . toInstance ( cvProp ) ; log . trace ( "Bound default override on method {}.{} scope {} to {}" , lastProxyMethodAndScope . getMethod ( ) . getDeclaringClass ( ) . getName ( ) , lastProxyMethodAndScope . getMethod ( ) . getName ( ) , scopeNameOpt , value . toString ( ) ) ; } ; }
Setup an override binding builder for a configuration interface .