Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2012 Palomino Labs, Inc.
  */
 
 package com.palominolabs.metrics.jersey;
 
final class ResourceMetricNamerImpl implements ResourceMetricNamer {
    @Nonnull
    @Override
        String metricId = getPathWithoutSurroundingSlashes(am.getResource().getPath());
        if (!metricId.isEmpty()) {
            metricId = "/" + metricId;
        }
        String httpMethod;
        if (am instanceof AbstractSubResourceMethod) {
            // if this is a subresource, add on the subresource's path component
            AbstractSubResourceMethod asrm = (AbstractSubResourceMethodam;
            metricId += "/" + getPathWithoutSurroundingSlashes(asrm.getPath());
            httpMethod = asrm.getHttpMethod();
        } else {
            httpMethod = am.getHttpMethod();
        }
        if (metricId.isEmpty()) {
            // this happens for WadlResource -- that case actually exists at "application.wadl" though
            metricId = "(no path)";
        }
        metricId += " " + httpMethod;
        return metricId;
    }
    @Nonnull
        if (pathValue == null) {
            return "";
        }
        String value = pathValue.getValue();
        if (value.startsWith("/")) {
            value = value.substring(1);
        }
        if (value.endsWith("/")) {
            value = value.substring(0, value.length() - 1);
        }
        return value;
    }
New to GrepCode? Check out our FAQ X