private void checkMerchantsSize(MerchantFilter merchantIds) { if (merchantIds == null) { return; } List include = merchantIds.getInclude(); List exclude = merchantIds.getExclude(); if (include != null && exclude != null) { throw new WrongFiltersException("Incorrect filter value: " + "'merchantIds' can't contain 'include' and 'exclude' ids at the same time."); } if (include == null && exclude == null) { throw new WrongFiltersException("Incorrect filter value: " + "'include' or 'exclude' field should be specified in 'merchantIds' filter"); } List merchants = include != null ? include : exclude; if (isNullOrEmpty(merchants)) { throw new WrongFiltersException("Incorrect filter value: " + "merchantIds filter should have at least one value in include or exclude array"); } } private static boolean isNullOrEmpty(List list) { return list == null || list.isEmpty(); }