code: public Double getPowerSourceMetric(String powerSourceName, ID metricToCollect) {
  
          Map<String, PowerSource> cache = getPowerSources();
          PowerSource powerSource = cache.get(powerSourceName);
          if (powerSource == null) {
              return null;
          }
  
          if (PlatformMetricType.POWER_SOURCE_REMAINING_CAPACITY.getMetricTypeId().equals(metricToCollect)) {
              return powerSource.getRemainingCapacity();
          } else if (PlatformMetricType.POWER_SOURCE_TIME_REMAINING.getMetricTypeId().equals(metricToCollect)) {
              return powerSource.getTimeRemaining();
          } else {
              throw new UnsupportedOperationException("Invalid power source metric to collect: " + metricToCollect);
          }
      }
docs: Returns the given metric's value, or null if there is no power source with the given name.
  
  @param powerSourceName name of power source
  @param metricToCollect the metric to collect
  @return the value of the metric, or null if there is no power source with the given name