String (final String productCode, String consentId) { if (productCode != null && consentId.endsWith(productCode) && (consentId.length() == productCode.length() || consentId.charAt(consentId.length() - productCode.length() - 1) == '.')) { return consentId.substring(0, consentId.length() - productCode.length() - 1); } return null; }