< prev index next >
core/org.openjdk.jmc.flightrecorder.rules/src/main/java/org/openjdk/jmc/flightrecorder/rules/util/RulesToolkit.java
Print this page
*** 143,169 ****
*/
public enum EventAvailability {
/**
* The type has events available in the collection.
*/
! AVAILABLE,
/**
* The type was actively enabled in the collection.
*/
! ENABLED,
/**
* The type was actively disabled in the collection.
*/
! DISABLED,
/**
* The type is known in the collection, but no events were found.
*/
! NONE,
/**
* The type is unknown in the collection.
*/
! UNAVAILABLE
}
/**
* @return a least squares approximation of the increase in memory over the given time period,
* in mebibytes/second
--- 143,200 ----
*/
public enum EventAvailability {
/**
* The type has events available in the collection.
*/
! AVAILABLE(4),
/**
* The type was actively enabled in the collection.
*/
! ENABLED(3),
/**
* The type was actively disabled in the collection.
*/
! DISABLED(2),
/**
* The type is known in the collection, but no events were found.
*/
! NONE(1),
/**
* The type is unknown in the collection.
*/
! UNKNOWN(0);
!
! /*
! * Used to determine the ordering of availabilities.
! */
! private final int availabilityScore;
!
! EventAvailability(int availabilityScore) {
! this.availabilityScore = availabilityScore;
! }
!
! /**
! * Returns true if this EventAvailability is more available than the provided one.
! *
! * @param availability
! * the {@link EventAvailability} to compare to.
! * @return true if this EventAvailability is more available than the provided one.
! */
! public boolean isMoreAvailableThan(EventAvailability availability) {
! return availabilityScore > availability.availabilityScore;
! }
!
! /**
! * Returns true if this EventAvailability is less available than the provided one.
! *
! * @param availability
! * the {@link EventAvailability} to compare to.
! * @return true if this EventAvailability is less available than the provided one.
! */
! public boolean isLessAvailableThan(EventAvailability availability) {
! return availabilityScore < availability.availabilityScore;
! }
}
/**
* @return a least squares approximation of the increase in memory over the given time period,
* in mebibytes/second
*** 384,394 ****
* the {@link EventAvailability} to check
* @return false if any {@link EventAvailability} is disabled or unavailable. Otherwise true.
*/
public static boolean isEventsEnabled(EventAvailability ... eventAvailabilities) {
for (EventAvailability availability : eventAvailabilities) {
! if (availability == EventAvailability.DISABLED || availability == EventAvailability.UNAVAILABLE) {
return false;
}
}
return true;
}
--- 415,425 ----
* the {@link EventAvailability} to check
* @return false if any {@link EventAvailability} is disabled or unavailable. Otherwise true.
*/
public static boolean isEventsEnabled(EventAvailability ... eventAvailabilities) {
for (EventAvailability availability : eventAvailabilities) {
! if (availability == EventAvailability.DISABLED || availability == EventAvailability.UNKNOWN) {
return false;
}
}
return true;
}
*** 434,444 ****
return EventAvailability.DISABLED;
}
if (isEventsKnown(items, typeIds)) {
return EventAvailability.NONE;
}
! return EventAvailability.UNAVAILABLE;
}
/**
* Checks if the event types are known in the collection. Note that it does not necessarily mean
* that there are events of the event type.
--- 465,489 ----
return EventAvailability.DISABLED;
}
if (isEventsKnown(items, typeIds)) {
return EventAvailability.NONE;
}
! return EventAvailability.UNKNOWN;
! }
!
! /**
! * Returns the lowest availability from the ones provided. See {@link EventAvailability}.
! */
! public static EventAvailability getLeastAvailable(EventAvailability ... availabilites) {
! EventAvailability lowest = EventAvailability.AVAILABLE;
!
! for (EventAvailability availability : availabilites) {
! if (availability.isLessAvailableThan(lowest)) {
! lowest = availability;
! }
! }
! return lowest;
}
/**
* Checks if the event types are known in the collection. Note that it does not necessarily mean
* that there are events of the event type.
*** 506,516 ****
return getNotApplicableResult(rule,
MessageFormat.format(Messages.getString(Messages.RulesToolkit_RULE_REQUIRES_EVENT_TYPE),
disabledEventTypeNames),
MessageFormat.format(Messages.getString(Messages.RulesToolkit_RULE_REQUIRES_EVENT_TYPE_LONG),
rule.getName(), disabledEventTypeNames));
! case UNAVAILABLE:
// Can't get type names if the event type is unavailable
List<String> quotedTypeIds = new ArrayList<>();
for (String typeId : typeIds) {
quotedTypeIds.add("'" + typeId + "'"); //$NON-NLS-1$ //$NON-NLS-2$
}
--- 551,561 ----
return getNotApplicableResult(rule,
MessageFormat.format(Messages.getString(Messages.RulesToolkit_RULE_REQUIRES_EVENT_TYPE),
disabledEventTypeNames),
MessageFormat.format(Messages.getString(Messages.RulesToolkit_RULE_REQUIRES_EVENT_TYPE_LONG),
rule.getName(), disabledEventTypeNames));
! case UNKNOWN:
// Can't get type names if the event type is unavailable
List<String> quotedTypeIds = new ArrayList<>();
for (String typeId : typeIds) {
quotedTypeIds.add("'" + typeId + "'"); //$NON-NLS-1$ //$NON-NLS-2$
}
< prev index next >