Esempio n. 1
0
 public ScopeMapping(@Nullable String defaultName, @Nullable Collection<String> names) {
   _defaultName = defaultName;
   _nameToMeasurePoints = new LinkedHashMap<>();
   if (names == null || names.isEmpty()) {
     _nameToMeasurePoints.put(defaultName, new MeasurePoints());
   } else {
     for (String possibleSpecificName : names) {
       _nameToMeasurePoints.put(possibleSpecificName, new MeasurePoints());
     }
   }
 }
Esempio n. 2
0
 /** Check if the given collection is a uniform collection of the given type. */
 public static boolean isUniformCollection(Collection<?> c, Class<?> e) {
   if (e == null) {
     throw new IllegalArgumentException("Null reference type");
   }
   if (c == null) {
     throw new IllegalArgumentException("Null collection");
   }
   if (c.isEmpty()) {
     return false;
   }
   for (Object o : c) {
     if (o == null || !e.isAssignableFrom(o.getClass())) {
       return false;
     }
   }
   return true;
 }
Esempio n. 3
0
 /**
  * Check if the given element denotes a supported array-friendly data structure, i.e. a data
  * structure jconsole can render as an array.
  */
 public static boolean canBeRenderedAsArray(Object elem) {
   if (isSupportedArray(elem)) return true;
   if (elem instanceof Collection) {
     Collection<?> c = (Collection<?>) elem;
     if (c.isEmpty()) {
       // Empty collections of any Java type are not handled as arrays
       //
       return false;
     } else {
       // - Collections of CompositeData/TabularData are not handled
       //   as arrays
       // - Collections of other Java types are handled as arrays
       //
       return !isUniformCollection(c, CompositeData.class)
           && !isUniformCollection(c, TabularData.class);
     }
   }
   if (elem instanceof Map) {
     return !(elem instanceof TabularData);
   }
   return false;
 }