private static Set<P11SlotIdentifier> getSlots(final SlotsType type) throws ConfigurationException { if (type == null || CollectionUtil.isEmpty(type.getSlot())) { return null; } Set<P11SlotIdentifier> slots = new HashSet<>(); for (SlotType slotType : type.getSlot()) { Long slotId = null; if (slotType.getId() != null) { String str = slotType.getId().trim(); try { if (StringUtil.startsWithIgnoreCase(str, "0X")) { slotId = Long.parseLong(str.substring(2), 16); } else { slotId = Long.parseLong(str); } } catch (NumberFormatException e) { String message = "invalid slotId '" + str + "'"; LOG.error(message); throw new ConfigurationException(message); } } slots.add(new P11SlotIdentifier(slotType.getIndex(), slotId)); } return slots; }