/** {@inheritDoc} */ public String getDisplayName() { return priority.getLongLocalizedString(); } }
private String getPriorityUrl(final Priority priority) { return url + "/" + priority.name(); }
/** * Returns a localized priority name. * * @param priorityName * priority as String value * @return localized priority name */ public String getLocalizedPriority(final String priorityName) { return Priority.fromString(priorityName).getLongLocalizedString(); }
/** * Returns whether the provided value is a valid priority. * * @param value the value to check * @return <code>true</code> if the provided value is a valid priority, <code>false</code> otherwise */ public boolean isPriority(final String value) { for (Priority priority : Priority.values()) { if (priority.toString().equalsIgnoreCase(value)) { return true; } } return false; }
/** * Returns all possible priorities. * * @return all priorities */ public Priority[] getPriorities() { return Priority.values(); } }
/** * Converts a String priority to an actual enumeration value. * * @param priority priority as a String * * @return enumeration value. */ private Priority getPriority(final String priority) { return Priority.fromString(priority); }
/** * Returns a tooltip showing the distribution of priorities for this container. * * @return a tooltip showing the distribution of priorities */ public String getToolTip() { StringBuilder message = new StringBuilder(); String separator = " - "; for (Priority priority : Priority.values()) { if (hasAnnotations(priority)) { message.append(priority.getLocalizedString()); message.append(":"); message.append(getNumberOfAnnotations(priority)); message.append(separator); } } return StringUtils.removeEnd(message.toString(), separator); }
/** {@inheritDoc} */ @Override public Object fromString(final String str) { return Priority.valueOf(str); } }
private void print(final HtmlPrinter printer, final Priority priority, final int count) { print(printer, priority.getLocalizedString(), count); }
@Override @SuppressWarnings("PMD") public int hashCode() { int prime = 31; int result = 1; result = prime * result + ((category == null) ? 0 : category.hashCode()); result = prime * result + ((fileName == null) ? 0 : fileName.hashCode()); result = prime * result + ((lineRanges == null) ? 0 : lineRanges.hashCode()); result = prime * result + ((message == null) ? 0 : message.hashCode()); result = prime * result + ((moduleName == null) ? 0 : moduleName.hashCode()); result = prime * result + ((packageName == null) ? 0 : packageName.hashCode()); result = prime * result + primaryLineNumber; result = prime * result + primaryColumnStart; result = prime * result + primaryColumnEnd; result = prime * result + ((priority == null) ? 0 : priority.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; }
/** * Computes the healthiness of a build based on the specified results. * Reports a health of 100% when the specified counter is less than * {@link #healthy}. Reports a health of 0% when the specified counter is * greater than {@link #unHealthy}. The computation takes only annotations * of the specified severity into account. * * @param result * annotations of the current build * @return the healthiness of a build */ public HealthReport computeHealth(final AnnotationProvider result) { int numberOfAnnotations = 0; for (Priority priority : Priority.collectPrioritiesFrom(healthDescriptor.getMinimumPriority())) { numberOfAnnotations += result.getNumberOfAnnotations(priority); } return computeHealth(numberOfAnnotations, result); }
/** * Creates a new priorities detail object. * * @param priority * the priority to show * @param owner * owner of the build * @param container * annotation container * @param header * header to show * @param defaultEncoding * the default encoding to be used when reading and parsing files * @return the priority detail */ public PrioritiesDetail create(final String priority, final AbstractBuild<?, ?> owner, final AnnotationContainer container, final String defaultEncoding, final String header) { if (Priority.HIGH.toString().equalsIgnoreCase(priority)) { return createPrioritiesDetail(Priority.HIGH, owner, container, defaultEncoding, header); } else if (Priority.NORMAL.toString().equalsIgnoreCase(priority)) { return createPrioritiesDetail(Priority.NORMAL, owner, container, defaultEncoding, header); } else if (Priority.LOW.toString().equalsIgnoreCase(priority)) { return createPrioritiesDetail(Priority.LOW, owner, container, defaultEncoding, header); } throw new IllegalArgumentException("Wrong priority provided: " + priority); }
/** * Returns all possible priorities. * * @return all priorities */ public Priority[] getPriorities() { return Priority.values(); }
/** * Converts a String priority to an actual enumeration value. * * @param priority priority as a String * * @return enumeration value. */ private Priority getPriority(final String priority) { return Priority.fromString(priority); }
/** * Returns whether the provided value is a valid priority. * * @param value the value to check * @return <code>true</code> if the provided value is a valid priority, <code>false</code> otherwise */ public boolean isPriority(final String value) { for (Priority priority : Priority.values()) { if (priority.toString().equalsIgnoreCase(value)) { return true; } } return false; }
/** * Returns a tooltip showing the distribution of priorities for this container. * * @return a tooltip showing the distribution of priorities */ public String getToolTip() { StringBuilder message = new StringBuilder(); String separator = " - "; for (Priority priority : Priority.values()) { if (hasAnnotations(priority)) { message.append(priority.getLocalizedString()); message.append(':'); message.append(getNumberOfAnnotations(priority)); message.append(separator); } } return StringUtils.removeEnd(message.toString(), separator); }
@Override public Object fromString(final String str) { return Priority.valueOf(str); } }
/** * Returns the annotations with {@link Priority#HIGH}. * * @return the annotations with {@link Priority#HIGH} */ public DefaultAnnotationContainer getHigh() { return new DefaultAnnotationContainer(Priority.HIGH.getLocalizedString(), getHighAnnotations()); }
@Override public int hashCode() { int result = message != null ? message.hashCode() : 0; result = 31 * result + (priority != null ? priority.hashCode() : 0); result = 31 * result + (lineRanges != null ? lineRanges.hashCode() : 0); result = 31 * result + primaryLineNumber; result = 31 * result + (fileName != null ? fileName.hashCode() : 0); result = 31 * result + (moduleName != null ? moduleName.hashCode() : 0); result = 31 * result + (packageName != null ? packageName.hashCode() : 0); result = 31 * result + (category != null ? category.hashCode() : 0); result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (origin != null ? origin.hashCode() : 0); result = 31 * result + (pathName != null ? pathName.hashCode() : 0); result = 31 * result + primaryColumnStart; result = 31 * result + primaryColumnEnd; return result; }
/** * Computes the healthiness of a build based on the specified results. * Reports a health of 100% when the specified counter is less than * {@link #healthy}. Reports a health of 0% when the specified counter is * greater than {@link #unHealthy}. The computation takes only annotations * of the specified severity into account. * * @param result * annotations of the current build * @return the healthiness of a build */ public HealthReport computeHealth(final AnnotationProvider result) { int numberOfAnnotations = 0; for (Priority priority : Priority.collectPrioritiesFrom(healthDescriptor.getMinimumPriority())) { numberOfAnnotations += result.getNumberOfAnnotations(priority); } return computeHealth(numberOfAnnotations, result); }