1 package org.openjdk.jmc.flightrecorder.ext.jfx;
   2 
   3 import org.openjdk.jmc.common.item.IAttribute;
   4 import org.openjdk.jmc.common.item.IItemCollection;
   5 import org.openjdk.jmc.common.unit.IQuantity;
   6 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit;
   7 import org.openjdk.jmc.flightrecorder.rules.util.RulesToolkit.EventAvailability;
   8 
   9 /**
  10  * Package local helper.
  11  */
  12 final class JfxVersionUtil {
  13         enum JavaFxEventAvailability {
  14                 None, JavaFx8, JavaFx12
  15         }
  16         
  17         static JavaFxEventAvailability getAvailability(IItemCollection items) {
  18                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JfxConstants.TYPE_ID_PULSE_PHASE_12);
  19                 if (RulesToolkit.isEventsEnabled(eventAvailability)) {
  20                         return JavaFxEventAvailability.JavaFx12;
  21                 }               
  22                 eventAvailability = RulesToolkit.getEventAvailability(items, JfxConstants.TYPE_ID_PULSE_PHASE_8);
  23                 if (RulesToolkit.isEventsEnabled(eventAvailability)) {
  24                         return JavaFxEventAvailability.JavaFx8;
  25                 }
  26                 return JavaFxEventAvailability.None;
  27         }
  28         
  29 
  30         static String getPulseTypeId(JavaFxEventAvailability availability) {
  31                 if (availability == JavaFxEventAvailability.JavaFx8) {
  32                         return JfxConstants.TYPE_ID_PULSE_PHASE_8;
  33                 }
  34                 return JfxConstants.TYPE_ID_PULSE_PHASE_12;
  35         }
  36 
  37 
  38         static IAttribute<IQuantity> getPulseIdAttribute(JavaFxEventAvailability availability) {
  39                 if (availability == JavaFxEventAvailability.JavaFx8) {
  40                         return JfxConstants.ATTRIBUTE_PULSE_ID_8;
  41                 }
  42                 return JfxConstants.ATTRIBUTE_PULSE_ID_12;
  43         }
  44 
  45 
  46         static IAttribute<String> getPhaseNameAttribute(JavaFxEventAvailability availability) {
  47                 if (availability == JavaFxEventAvailability.JavaFx8) {
  48                         return JfxConstants.ATTRIBUTE_PHASE_NAME_8;
  49                 }
  50                 return JfxConstants.ATTRIBUTE_PHASE_NAME_12;
  51         }
  52 }