code: private RenditionMetadata getExactMatchRendition(final Set<RenditionMetadata> candidates, MediaArgs mediaArgs) {
      // check for fixed width and/or height request
      if (mediaArgs.getFixedWidth() > 0 || mediaArgs.getFixedHeight() > 0) {
        for (RenditionMetadata candidate : candidates) {
          if (candidate.matches(mediaArgs.getFixedWidth(), mediaArgs.getFixedHeight())) {
            return candidate;
          }
        }
      }
  
      // otherwise check for media format restriction
      else if (mediaArgs.getMediaFormats() != null && mediaArgs.getMediaFormats().length > 0) {
        return visitMediaFormats(mediaArgs, new MediaFormatVisitor<RenditionMetadata>() {
          @Override
          public RenditionMetadata visit(MediaFormat mediaFormat) {
            for (RenditionMetadata candidate : candidates) {
              if (candidate.matches((int)mediaFormat.getEffectiveMinWidth(),
                  (int)mediaFormat.getEffectiveMinHeight(),
                  (int)mediaFormat.getEffectiveMaxWidth(),
                  (int)mediaFormat.getEffectiveMaxHeight(),
                  mediaFormat.getRatio())) {
                candidate.setMediaFormat(mediaFormat);
                return candidate;
              }
            }
            return null;
          }
        });
      }
  
      // no restriction - return original or first rendition
      else {
        return getOriginalOrFirstRendition(candidates);
      }
  
      // none found
      return null;
    }
docs: Get rendition that matches exactly with the given media args requirements.
  @param candidates Rendition candidates
  @param mediaArgs Media args
  @return Rendition or null if none found