Jammed finger. You need to make sure that there is no fracture nor any significant ligament or tendon injury. Check with your doctor to find out for sure. If diagnosis is correct, range of motion exercises are extremely important. Modalities to reduce swelling include ice, elevation, and nsaids. Heat helps warm up and loosen joint aiding in range of motion.
Ice, rest. The first steps to treating such an injury is icing and elevating the finger. Ice the injury for 15 minutes and then remove the ice until the finger temperature returns to normal. Then repeat the process. After the swelling decreases and the pain subsides, try to move the finger very slightly. If the injury is mild, you will be able to move with little discomfort over a short time.