@Override public Map<String, Object> attributes() { return route.attributes(); }
private boolean hasAttributes(final Route[] routes) { for (int i = 0; i < routes.length; i++) { if (routes[i].attributes().size() > 0) { return true; } } return false; }
/** * Attribute by name. * * @param name Attribute's name. * @param <T> Attribute's type. * @return Attribute value. */ @SuppressWarnings("unchecked") @Nonnull default <T> T attr(final String name) { return (T) attributes().get(name); }
private static Route attrs(final Route route, final Route[] routes, final int i) { Map<String, Object> attrs = new HashMap<>(16); for (int t = i; t < routes.length; t++) { routes[t].attributes().forEach((name, value) -> attrs.putIfAbsent(name, value)); } return new Route.Forwarding(route) { @Override public <T> T attr(String name) { return (T) attrs.get(name); } @Override public Map<String, Object> attributes() { return attrs; } }; }
public static TimedSupport create(Route route) { Map<String, Object> attributes = route.attributes(); String timed = (String) attributes.get("timed"); if (timed != null) { String[] extraTags = (String[]) attributes.get("timed.extraTags"); boolean histogram = attributes.get("timed.histogram") == Boolean.TRUE; double[] percentiles = (double[]) attributes.get("timed.percentiles"); boolean longTask = attributes.get("timed.longTask") == Boolean.TRUE; String description = Strings.emptyToNull((String) attributes.get("timed.description")); return new TimedSupport(timed, longTask, description, extraTags, histogram, percentiles); } return null; } }
.put("pattern", route.pattern()) .put("name", route.name()) .put("attributes", route.attributes()).build(); }));
@Override public Map<String, Object> attributes() { return route.attributes(); }
private boolean hasAttributes(final Route[] routes) { for (int i = 0; i < routes.length; i++) { if (routes[i].attributes().size() > 0) { return true; } } return false; }
/** * Attribute by name. * * @param name Attribute's name. * @param <T> Attribute's type. * @return Attribute value. */ @SuppressWarnings("unchecked") @Nonnull default <T> T attr(final String name) { return (T) attributes().get(name); }
private static Route attrs(final Route route, final Route[] routes, final int i) { Map<String, Object> attrs = new HashMap<>(16); for (int t = i; t < routes.length; t++) { routes[t].attributes().forEach((name, value) -> attrs.putIfAbsent(name, value)); } return new Route.Forwarding(route) { @Override public <T> T attr(String name) { return (T) attrs.get(name); } @Override public Map<String, Object> attributes() { return attrs; } }; }
.put("pattern", route.pattern()) .put("name", route.name()) .put("attributes", route.attributes()).build(); }));