in application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/JfrPropertySheet.java [604:693]
private static <M> PropertySheetRow buildProperty(
IAttribute<M> attribute, Iterator<? extends IItemIterable> iterables, int maxDistinct) {
ContentType<M> contentType = attribute.getContentType();
if (contentType instanceof KindOfQuantity) {
@SuppressWarnings("unchecked")
IAttribute<IQuantity> qAttribute = (IAttribute<IQuantity>) attribute;
IQuantity minValue = null;
IQuantity maxValue = null;
while (iterables.hasNext()) {
IItemIterable ii = iterables.next();
IMemberAccessor<IQuantity, IItem> accessor = qAttribute.getAccessor(ii.getType());
Iterator<? extends IItem> items = ii.iterator();
while (items.hasNext()) {
IQuantity val = accessor.getMember(items.next());
if (val == null) {
// FIXME: Should null values be expected/accepted?
// FlightRecorderUI.getDefault().getLogger().warning("Null value in " + qAttribute.getIdentifier() + " field"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (minValue == null) {
minValue = maxValue = val;
} else {
minValue = QuantitiesToolkit.min(val, minValue);
maxValue = QuantitiesToolkit.max(val, maxValue);
}
}
}
if (minValue != null) {
if (minValue == maxValue) {
return new PropertySheetRow(qAttribute, minValue);
} else {
return new PropertySheetRow(qAttribute, QuantityRange.createWithEnd(minValue, maxValue));
}
}
} else if (contentType instanceof RangeContentType) {
if (((RangeContentType<?>) contentType).getEndPointContentType() instanceof KindOfQuantity) {
@SuppressWarnings("unchecked")
IAttribute<IRange<IQuantity>> rangeAttribute = (IAttribute<IRange<IQuantity>>) attribute;
IQuantity minValue = null;
IQuantity maxValue = null;
while (iterables.hasNext()) {
IItemIterable ii = iterables.next();
IMemberAccessor<IRange<IQuantity>, IItem> accessor = rangeAttribute.getAccessor(ii.getType());
Iterator<? extends IItem> items = ii.iterator();
while (items.hasNext()) {
IRange<IQuantity> range = accessor.getMember(items.next());
if (range == null) {
// FIXME: Should null values be expected/accepted?
// FlightRecorderUI.getDefault().getLogger().warning("Null value in " + rangeAttribute.getIdentifier() + " field"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (minValue == null) {
minValue = range.getStart();
maxValue = range.getEnd();
} else {
minValue = QuantitiesToolkit.min(range.getStart(), minValue);
maxValue = QuantitiesToolkit.max(range.getEnd(), maxValue);
}
}
}
if (minValue != null) {
if (minValue == maxValue) {
return new PropertySheetRow(rangeAttribute, minValue);
} else {
return new PropertySheetRow(rangeAttribute, QuantityRange.createWithEnd(minValue, maxValue));
}
}
}
}
Set<M> keys = new HashSet<>();
while (iterables.hasNext()) {
IItemIterable ii = iterables.next();
IMemberAccessor<M, IItem> accessor = attribute.getAccessor(ii.getType());
Iterator<? extends IItem> items = ii.iterator();
while (items.hasNext()) {
if (keys.size() > maxDistinct) {
return new PropertySheetRow(attribute, TOO_MANY_VALUES);
}
// FIXME: Add more limitations if there are a lot of items?
keys.add(accessor.getMember(items.next()));
}
}
if (keys.size() == 0) {
return null;
} else if (keys.size() == 1) {
return new PropertySheetRow(attribute, keys.iterator().next());
} else {
return new PropertySheetRow(attribute, keys);
}
}