class ReferenceClientImpl implements ReferenceClient {

    private final SofaRuntimeContext      sofaRuntimeContext;

    private final BindingConverterFactory bindingConverterFactory;

    private final BindingAdapterFactory   bindingAdapterFactory;

    public ReferenceClientImpl(SofaRuntimeContext sofaRuntimeContext,
                               BindingConverterFactory bindingConverterFactory,
                               BindingAdapterFactory bindingAdapterFactory) {
        this.sofaRuntimeContext = sofaRuntimeContext;
        this.bindingConverterFactory = bindingConverterFactory;
        this.bindingAdapterFactory = bindingAdapterFactory;
    }

    @SuppressWarnings("unchecked")
    private <T> Reference getReferenceFromReferenceParam(ReferenceParam<T> referenceParam) {<FILL_FUNCTION_BODY>}

    @SuppressWarnings("unchecked")
    @Override
    public <T> T reference(ReferenceParam<T> referenceParam) {

        return (T) ReferenceRegisterHelper.registerReference(
            getReferenceFromReferenceParam(referenceParam), bindingAdapterFactory,
            sofaRuntimeContext);
    }

    @Override
    public <T> void removeReference(ReferenceParam<T> referenceParam) {
        Reference reference = getReferenceFromReferenceParam(referenceParam);
        ComponentName referenceComponentName = ComponentNameFactory.createComponentName(
            ReferenceComponent.REFERENCE_COMPONENT_TYPE,
            reference.getInterfaceType(),
            reference.getUniqueId() + "#"
                    + ReferenceRegisterHelper.generateBindingHashCode(reference));
        Collection<ComponentInfo> referenceComponents = sofaRuntimeContext.getComponentManager()
            .getComponentInfosByType(ReferenceComponent.REFERENCE_COMPONENT_TYPE);

        for (ComponentInfo referenceComponent : referenceComponents) {
            if (referenceComponent.getName().equals(referenceComponentName)) {
                sofaRuntimeContext.getComponentManager().unregister(referenceComponent);
            }
        }
    }

    @Override
    public void removeReference(Class<?> interfaceClass) {
        removeReference(interfaceClass, "");
    }

    @Override
    public void removeReference(Class<?> interfaceClass, String uniqueId) {
        Collection<ComponentInfo> referenceComponents = sofaRuntimeContext.getComponentManager()
            .getComponentInfosByType(ReferenceComponent.REFERENCE_COMPONENT_TYPE);
        for (ComponentInfo componentInfo : referenceComponents) {
            if (!(componentInfo instanceof ReferenceComponent)) {
                continue;
            }
            ReferenceComponent referenceComponent = (ReferenceComponent) componentInfo;
            if (referenceComponent.getReference().getInterfaceType() == interfaceClass
                && referenceComponent.getReference().getUniqueId().equals(uniqueId)) {
                sofaRuntimeContext.getComponentManager().unregister(referenceComponent);
            }
        }
    }
}

        BindingParam bindingParam = referenceParam.getBindingParam();
        Reference reference = new ReferenceImpl(referenceParam.getUniqueId(),
            referenceParam.getInterfaceType(), InterfaceMode.api, referenceParam.isJvmFirst(), null);
        reference.setRequired(referenceParam.isRequired());

        if (bindingParam == null) {
            // default add jvm binding and reference jvm binding should set serialize as false
            JvmBindingParam jvmBindingParam = new JvmBindingParam();
            jvmBindingParam.setSerialize(false);
            reference.addBinding(new JvmBinding().setJvmBindingParam(jvmBindingParam));
        } else {
            BindingConverter bindingConverter = bindingConverterFactory
                .getBindingConverter(bindingParam.getBindingType());
            if (bindingConverter == null) {
                throw new ServiceRuntimeException(ErrorCode.convert("01-00200",
                    bindingParam.getBindingType()));
            }
            BindingConverterContext bindingConverterContext = new BindingConverterContext();
            bindingConverterContext.setInBinding(true);
            bindingConverterContext.setAppName(sofaRuntimeContext.getAppName());
            bindingConverterContext.setAppClassLoader(sofaRuntimeContext.getAppClassLoader());
            Binding binding = bindingConverter.convert(bindingParam, bindingConverterContext);
            reference.addBinding(binding);
        }

        return reference;
    
<no_super_class>