Example #1
0
  /**
   * Procedure to convert selector string to value selector class.
   *
   * @param valueSelectorText selector string e.g. RawData, Command, Temperature
   * @return corresponding selector value.
   * @throws InvalidClassException Not valid class for value selector.
   */
  public static RMEValueSelector getValueSelector(String valueSelectorText)
      throws IllegalArgumentException {

    for (RMEValueSelector c : RMEValueSelector.values()) {
      if (c.text.equals(valueSelectorText)) {
        return c;
      }
    }

    throw new IllegalArgumentException("Not valid value selector");
  }
Example #2
0
  /**
   * Procedure to validate selector string.
   *
   * @param valueSelector selector string e.g. RawData, Command, Temperature
   * @return true if item is valid.
   * @throws IllegalArgumentException Not valid value selector.
   * @throws InvalidClassException Not valid class for value selector.
   */
  public static boolean validateBinding(String valueSelector, Item item)
      throws IllegalArgumentException, InvalidClassException {

    for (RMEValueSelector c : RMEValueSelector.values()) {
      if (c.text.equals(valueSelector) && item != null) {

        logger.debug("Accepted types are {}", item.getAcceptedDataTypes());
        logger.debug("typeclass is {}", c.getTypeClass());

        if (item.getAcceptedDataTypes().contains(c.getTypeClass())) return true;
        else throw new InvalidClassException("Not valid class for value selector");
      }
    }

    throw new IllegalArgumentException("Not valid value selector");
  }