Utils.java [src/edit] Revision: 33d29b967cf0533bfd3a2bf80268569a6f6d005b  Date: Tue Mar 16 10:43:17 MDT 2021
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package edit;

/**
 * EDIT Utils.
 *
 * @author od
 */
public class Utils {

  // check 'R053CY004SD'
  public static void checkEcoclassId(String ecId) {
    if (ecId.length() != 11
        || (ecId.charAt(0) != 'R' && ecId.charAt(0) != 'F')) {
      throw new IllegalArgumentException("Invalid ecoclassid: " + ecId);
    }
  }


  // R053CY004SD -> 053C
  public static String getMLRA(String ecId) {
    checkEcoclassId(ecId);
    return ecId.substring(1, 5);
  }

}