List of usage examples for java.util LinkedList getFirst
public E getFirst()
From source file:org.quickconnectfamily.json.JSONParser.java
/** * Parse JSON text into java object from the input source. * //from w w w . j a v a2 s. com * @param in * @param containerFactory - Use this factory to create your own JSON object and JSON array containers. * @return Instance of the following: * org.json.simple.JSONObject, * org.json.simple.JSONArray, * java.lang.String, * java.lang.Number, * java.lang.Boolean, * null * * @throws IOException * @throws ParseException */ @SuppressWarnings({ "unchecked", "rawtypes" }) public Object parse(ContainerFactory containerFactory) throws IOException, ParseException { LinkedList statusStack = new LinkedList(); LinkedList valueStack = new LinkedList(); try { do { if (status != S_IN_FINISHED_VALUE) { nextToken(); } switch (status) { case S_INIT: switch (token.type) { case Yytoken.TYPE_VALUE: status = S_IN_FINISHED_VALUE; statusStack.addFirst(new Integer(status)); valueStack.addFirst(token.value); break; case Yytoken.TYPE_LEFT_BRACE: if (firstCharType == FIRST_JSON_CHAR_TYPE_UNSET) { firstCharType = Yytoken.TYPE_LEFT_BRACE; } if (firstCharType == Yytoken.TYPE_LEFT_BRACE) { numUnmatchedCharTypeCount++; } status = S_IN_OBJECT; statusStack.addFirst(new Integer(status)); valueStack.addFirst(createObjectContainer(containerFactory)); break; case Yytoken.TYPE_LEFT_SQUARE: if (firstCharType == FIRST_JSON_CHAR_TYPE_UNSET) { firstCharType = Yytoken.TYPE_LEFT_SQUARE; } if (firstCharType == Yytoken.TYPE_LEFT_SQUARE) { numUnmatchedCharTypeCount++; } status = S_IN_ARRAY; statusStack.addFirst(new Integer(status)); valueStack.addFirst(createArrayContainer(containerFactory)); break; default: status = S_IN_ERROR; }//inner switch break; case S_IN_FINISHED_VALUE: if (token.type == Yytoken.TYPE_EOF || numUnmatchedCharTypeCount == 0) { firstCharType = FIRST_JSON_CHAR_TYPE_UNSET; status = S_INIT; return valueStack.removeFirst(); } else throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token); case S_IN_OBJECT: switch (token.type) { case Yytoken.TYPE_COMMA: break; case Yytoken.TYPE_VALUE: if (token.value instanceof String) { String key = (String) token.value; valueStack.addFirst(key); status = S_PASSED_PAIR_KEY; statusStack.addFirst(new Integer(status)); } else { status = S_IN_ERROR; } break; case Yytoken.TYPE_RIGHT_BRACE: if (firstCharType == Yytoken.TYPE_LEFT_BRACE) { numUnmatchedCharTypeCount--; } if (valueStack.size() > 1) { statusStack.removeFirst(); valueStack.removeFirst(); status = peekStatus(statusStack); } else { status = S_IN_FINISHED_VALUE; } break; default: status = S_IN_ERROR; break; }//inner switch break; case S_PASSED_PAIR_KEY: switch (token.type) { case Yytoken.TYPE_COLON: break; case Yytoken.TYPE_VALUE: statusStack.removeFirst(); String key = (String) valueStack.removeFirst(); Map parent = (Map) valueStack.getFirst(); parent.put(key, token.value); status = peekStatus(statusStack); break; case Yytoken.TYPE_LEFT_SQUARE: if (firstCharType == Yytoken.TYPE_LEFT_SQUARE) { numUnmatchedCharTypeCount++; } statusStack.removeFirst(); key = (String) valueStack.removeFirst(); parent = (Map) valueStack.getFirst(); List newArray = createArrayContainer(containerFactory); parent.put(key, newArray); status = S_IN_ARRAY; statusStack.addFirst(new Integer(status)); valueStack.addFirst(newArray); break; case Yytoken.TYPE_LEFT_BRACE: if (firstCharType == Yytoken.TYPE_LEFT_BRACE) { numUnmatchedCharTypeCount++; } statusStack.removeFirst(); key = (String) valueStack.removeFirst(); parent = (Map) valueStack.getFirst(); Map newObject = createObjectContainer(containerFactory); parent.put(key, newObject); status = S_IN_OBJECT; statusStack.addFirst(new Integer(status)); valueStack.addFirst(newObject); break; default: status = S_IN_ERROR; } break; case S_IN_ARRAY: switch (token.type) { case Yytoken.TYPE_COMMA: break; case Yytoken.TYPE_VALUE: List val = (List) valueStack.getFirst(); val.add(token.value); break; case Yytoken.TYPE_RIGHT_SQUARE: if (firstCharType == Yytoken.TYPE_LEFT_SQUARE) { numUnmatchedCharTypeCount--; } if (valueStack.size() > 1) { statusStack.removeFirst(); valueStack.removeFirst(); status = peekStatus(statusStack); } else { status = S_IN_FINISHED_VALUE; } break; case Yytoken.TYPE_LEFT_BRACE: if (firstCharType == Yytoken.TYPE_LEFT_BRACE) { numUnmatchedCharTypeCount++; } val = (List) valueStack.getFirst(); Map newObject = createObjectContainer(containerFactory); val.add(newObject); status = S_IN_OBJECT; statusStack.addFirst(new Integer(status)); valueStack.addFirst(newObject); break; case Yytoken.TYPE_LEFT_SQUARE: if (firstCharType == Yytoken.TYPE_LEFT_SQUARE) { numUnmatchedCharTypeCount++; } val = (List) valueStack.getFirst(); List newArray = createArrayContainer(containerFactory); val.add(newArray); status = S_IN_ARRAY; statusStack.addFirst(new Integer(status)); valueStack.addFirst(newArray); break; default: status = S_IN_ERROR; }//inner switch break; case S_IN_ERROR: throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token); }//switch if (status == S_IN_ERROR) { throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token); } } while (token.type != Yytoken.TYPE_EOF); } catch (IOException ie) { throw ie; } throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token); }
From source file:net.spfbl.core.Analise.java
public static void processIP(String ip, StringBuilder builder, int timeout) { try {//from w w w . j a va2s . co m ip = Subnet.normalizeIP(ip); Distribution dist = SPF.getDistribution(ip, false); float probability = dist == null ? 0.0f : dist.getSpamProbability(ip); boolean ipv4 = SubnetIPv4.isValidIPv4(ip); Object response = null; Status statusIP; String tokenName; Status statusName = Status.NONE; LinkedList<String> nameList = new LinkedList<String>(); try { for (String ptr : Reverse.getPointerSet(ip)) { nameList.add(ptr); if (Generic.containsDynamic(ptr)) { statusName = Status.DYNAMIC; break; } else if (Block.containsDomain(ptr, false)) { statusName = Status.BLOCK; } else if (Block.containsREGEX(ptr)) { statusName = Status.BLOCK; } else if (Block.containsWHOIS(ptr)) { statusName = Status.BLOCK; } else if (Generic.containsGeneric(ptr)) { statusName = Status.GENERIC; } else { try { if (Reverse.getAddressSet(ptr).contains(ip)) { Distribution distPTR; if (White.containsDomain(ptr)) { statusName = Status.WHITE; break; } else if (Provider.containsDomain(ptr)) { statusName = Status.PROVIDER; break; } else if (Ignore.contains(ptr)) { statusName = Status.IGNORE; break; } else if ((distPTR = SPF.getDistribution(ptr, false)) == null) { statusName = Status.GREEN; break; } else { statusName = Status.valueOf(distPTR.getStatus(ptr).name()); break; } } else { statusName = Status.INVALID; } } catch (NamingException ex) { statusName = Status.NXDOMAIN; } } } } catch (CommunicationException ex) { statusName = Status.TIMEOUT; } catch (ServiceUnavailableException ex) { statusName = Status.UNAVAILABLE; } catch (NamingException ex) { statusName = Status.NONE; } if (White.containsIP(ip)) { statusIP = Status.WHITE; } else if (Block.containsCIDR(ip)) { statusIP = Status.BLOCK; } else if (Provider.containsCIDR(ip)) { statusIP = Status.PROVIDER; } else if (Ignore.containsCIDR(ip)) { statusIP = Status.IGNORE; } else if (Block.containsDNSBL(ip)) { statusIP = Status.DNSBL; } else if (statusName == Status.TIMEOUT && hasAccessSMTP(ip) && (response = getResponseSMTP(ip, 25, timeout)) instanceof Status) { statusIP = (Status) response; } else if (statusName == Status.UNAVAILABLE && hasAccessSMTP(ip) && (response = getResponseSMTP(ip, 25, timeout)) instanceof Status) { statusIP = (Status) response; } else if (statusName == Status.NONE && hasAccessSMTP(ip) && (response = getResponseSMTP(ip, 25, timeout)) instanceof Status) { statusIP = (Status) response; } else if (dist == null) { statusIP = Status.GREEN; } else { statusIP = Status.valueOf(dist.getStatus(ip).name()); } if (response instanceof String) { nameList.addLast((String) response); } if (statusName == Status.TIMEOUT) { tokenName = ip; } else if (statusName == Status.UNAVAILABLE) { tokenName = ip; } else if (nameList.isEmpty()) { tokenName = ip; statusName = Status.NONE; } else { tokenName = nameList.getFirst(); statusName = Status.INVALID; } for (String name : nameList) { if (Generic.containsDynamic(name)) { tokenName = name; statusName = Status.DYNAMIC; break; } else if (Block.containsDomain(name, false)) { tokenName = name; statusName = Status.BLOCK; break; } else if (Block.containsREGEX(name)) { tokenName = name; statusName = Status.BLOCK; break; } else if (Block.containsWHOIS(name)) { tokenName = name; statusName = Status.BLOCK; break; } else if (Generic.containsGeneric(name)) { tokenName = name; statusName = Status.GENERIC; break; } else { try { if (Reverse.getAddressSet(name).contains(ip)) { if (White.containsDomain(name)) { tokenName = name; statusName = Status.WHITE; break; } else if (Provider.containsDomain(name)) { tokenName = name; statusName = Status.PROVIDER; break; } else if (Ignore.contains(name)) { tokenName = name; statusName = Status.IGNORE; break; } else { tokenName = name; Distribution distribution2 = SPF.getDistribution(name, false); if (distribution2 == null) { statusName = Status.GREEN; } else { statusName = Status.valueOf(distribution2.getStatus(name).name()); } } } } catch (NameNotFoundException ex) { tokenName = name; statusName = Status.NXDOMAIN; } catch (NamingException ex) { // Fazer nada. } } } if (statusName == Status.INVALID || statusName == Status.NXDOMAIN) { try { String domain = Domain.extractDomain(tokenName, true); if (!Reverse.hasValidNameServers(domain)) { if (Block.addExact(domain)) { statusName = Status.BLOCK; Server.logDebug("new BLOCK '" + domain + "' added by 'NXDOMAIN'."); Peer.sendBlockToAll(domain); } } } catch (NamingException ex) { // Fazer nada. } catch (ProcessException ex) { if (ex.isErrorMessage("RESERVED")) { statusName = Status.RESERVED; } else { Server.logError(ex); } } } if (statusIP != Status.BLOCK && statusName == Status.DYNAMIC) { String token = ip + (SubnetIPv4.isValidIPv4(ip) ? "/24" : "/48"); String cidr = Subnet.normalizeCIDR(token); if (Block.tryOverlap(cidr)) { Server.logDebug("new BLOCK '" + token + "' added by '" + tokenName + ";" + statusName + "'."); } else if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusName + "'."); } String previous = Subnet.getFirstIP(cidr); previous = Subnet.getPreviousIP(previous); previous = Subnet.getPreviousIP(previous); Analise.processToday(previous); String next = Subnet.getLastIP(cidr); next = Subnet.getNextIP(next); next = Subnet.getNextIP(next); Analise.processToday(next); statusIP = Status.BLOCK; } else if (statusIP != Status.BLOCK && statusName == Status.NONE) { String token = ip + (ipv4 ? "/32" : "/64"); String cidr = Subnet.normalizeCIDR(token); if (Block.tryOverlap(cidr)) { Server.logDebug("new BLOCK '" + token + "' added by '" + tokenName + ";" + statusName + "'."); } else if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusName + "'."); } if (ipv4) { cidr = Subnet.normalizeCIDR(ip + "/24"); String next = Subnet.getFirstIP(cidr); for (int index = 0; index < 256; index++) { if (!hasReverse(next) && Block.tryAdd(next)) { Server.logDebug("new BLOCK '" + next + "' added by '" + next + ";" + statusName + "'."); } next = Subnet.getNextIP(next); } } statusIP = Status.BLOCK; } else if (statusIP != Status.BLOCK && (statusName == Status.BLOCK || statusName == Status.RESERVED || statusName == Status.NXDOMAIN)) { if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusName + "'."); } statusIP = Status.BLOCK; } else if (statusIP != Status.BLOCK && statusIP != Status.IGNORE && statusName != Status.PROVIDER && statusName != Status.IGNORE && statusName != Status.GREEN && statusName != Status.WHITE && SubnetIPv6.isSLAAC(ip)) { String token = ip + "/64"; String cidr = SubnetIPv6.normalizeCIDRv6(token); if (Block.tryOverlap(cidr)) { Server.logDebug("new BLOCK '" + token + "' added by 'SLAAC'."); } else if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by 'SLAAC'."); } statusIP = Status.BLOCK; // } else if (statusIP != Status.BLOCK && statusIP != Status.IGNORE && statusIP != Status.WHITE && statusName != Status.PROVIDER && statusName != Status.IGNORE && statusName != Status.WHITE && isCusterRED(ip, null, tokenName)) { // if (Block.tryAdd(ip)) { // Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";CLUSTER'."); // } // statusIP = Status.BLOCK; } else if (statusIP == Status.DNSBL && (statusName != Status.GREEN && statusName != Status.PROVIDER && statusName != Status.IGNORE && statusName != Status.WHITE)) { if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusIP + "'."); } statusIP = Status.BLOCK; } else if (statusIP == Status.CLOSED && statusName == Status.RED) { if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusIP + "'."); } statusIP = Status.BLOCK; } else if (statusIP != Status.BLOCK && statusName == Status.INVALID && Generic.containsGenericDomain(tokenName)) { if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusName + "'."); } statusIP = Status.BLOCK; } else if ((statusName == Status.INVALID || statusName == Status.GENERIC) && (statusIP == Status.CLOSED || statusIP == Status.RED || statusIP == Status.YELLOW)) { if (Block.tryAdd(ip)) { Server.logDebug("new BLOCK '" + ip + "' added by '" + tokenName + ";" + statusName + "'."); } statusIP = Status.BLOCK; } else if (statusIP == Status.BLOCK && (statusName == Status.YELLOW || statusName == Status.RED)) { if (Block.tryAdd(tokenName)) { Server.logDebug( "new BLOCK '" + tokenName + "' added by '" + tokenName + ";" + statusName + "'."); } statusName = Status.BLOCK; } else if (statusIP == Status.BLOCK && (statusName == Status.PROVIDER || statusName == Status.IGNORE || statusName == Status.WHITE)) { String cidr; int mask = SubnetIPv4.isValidIPv4(ip) ? 32 : 64; if ((cidr = Block.clearCIDR(ip, mask)) != null) { Server.logInfo("false positive BLOCK '" + cidr + "' detected by '" + tokenName + ";" + statusName + "'."); } if (Provider.containsCIDR(ip)) { statusIP = Status.PROVIDER; } else if (Ignore.containsCIDR(ip)) { statusIP = Status.IGNORE; } else if (Block.containsDNSBL(ip)) { statusIP = Status.DNSBL; } else if (hasAccessSMTP(ip) && (response = getResponseSMTP(ip, 25, timeout)) instanceof Status) { statusIP = (Status) response; } else if (dist == null) { statusIP = Status.GREEN; } else { statusIP = Status.valueOf(dist.getStatus(ip).name()); } } else if (statusIP == Status.DNSBL && (statusName == Status.PROVIDER || statusName == Status.IGNORE || statusName == Status.WHITE)) { if (hasAccessSMTP(ip) && (response = getResponseSMTP(ip, 25, timeout)) instanceof Status) { statusIP = (Status) response; } else if (dist == null) { statusIP = Status.GREEN; } else { statusIP = Status.valueOf(dist.getStatus(ip).name()); } } builder.append(statusIP); builder.append(' '); builder.append(tokenName); builder.append(' '); builder.append(statusName); builder.append(' '); builder.append(Core.DECIMAL_FORMAT.format(probability)); builder.append(' '); builder.append(dist == null ? "UNDEFINED" : dist.getFrequencyLiteral()); builder.append(' '); if (Subnet.isValidIP(tokenName)) { builder.append(Subnet.expandIP(tokenName)); } else { builder.append(Domain.revert(tokenName)); addCluster(convertHostToMask(tokenName), statusName, dist); addCluster(extractTLD(tokenName), statusName, dist); addCluster(getOwnerID(tokenName), statusName, dist); } addCluster(Subnet.normalizeCIDR(ip + (ipv4 ? "/24" : "/56")), statusIP, dist); } catch (Exception ex) { builder.append("ERROR"); Server.logError(ex); } }
From source file:com.ikanow.infinit.e.harvest.extraction.document.file.FileHarvester.java
private void processFiles(SourcePojo source) throws Exception { // Can override system settings if less: if ((null != source.getThrottleDocs()) && (source.getThrottleDocs() < maxDocsPerCycle)) { maxDocsPerCycle = source.getThrottleDocs(); }/*from ww w .j av a 2 s.c o m*/ sourceUrlsGettingUpdated = new HashSet<String>(); LinkedList<String> duplicateSources = new LinkedList<String>(); try { // Compile regexes if they are present if ((null != source.getFileConfig()) && (null != source.getFileConfig().pathInclude)) { includeRegex = Pattern.compile(source.getFileConfig().pathInclude, Pattern.CASE_INSENSITIVE); } if ((null != source.getFileConfig()) && (null != source.getFileConfig().pathExclude)) { excludeRegex = Pattern.compile(source.getFileConfig().pathExclude, Pattern.CASE_INSENSITIVE); } if ((null != source.getFileConfig()) && (null != source.getFileConfig().maxDepth)) { this.maxDepth = source.getFileConfig().maxDepth; } // Process the fileshare getFiles(source); } catch (Exception e) { // If an exception here this is catastrophic, throw it upwards: errors++; throw e; } try { //Dedup code, ironically enough partly duplicated in parse(), probably unnecessarily DuplicateManager qr = _context.getDuplicateManager(); for (DocumentPojo doc : files) { try { duplicateSources.clear(); if (null != doc.getSourceUrl()) { boolean add = true; // However still need to check for duplicates so can update entities correctly (+maintain _ids, etc) // We only do this if the source URL changes (unless URL is taken from the object in which case all bets are off) boolean sourceUrlUpdated = sourceUrlsGettingUpdated.contains(doc.getSourceUrl()); if (!doc.getHasDefaultUrl() || sourceUrlUpdated) { // src URL for a given URL // (only if the the sourceUrl is not new...) if (qr.isDuplicate_Url(doc.getUrl(), source, duplicateSources)) { doc.setUpdateId(qr.getLastDuplicateId()); // (set _id to doc we're going to replace) if (!sourceUrlUpdated && !_deleteExistingFilesBySourceKey) { // Here update instead so we delete the old doc and add the new one add = false; docsToUpdate.add(doc); } //TESTED else { // (else *still* don't add this to updates because we've added the source URL or source key to the delete list) // (hence approximate create with the updateId...) if (null != doc.getUpdateId()) { doc.setCreated(new Date(doc.getUpdateId().getTime())); } //TESTED } //TESTED } //(note we don't get about duplicate sources in this case - just too complex+rare a case) } //TESTED (src url changing, different src url, non-default URL) // For composite files we (almost always) delete everything that already exists (via docsToRemove) and then add new docs if (add) { docsToAdd.add(doc); } //TESTED } else if (qr.isDuplicate_Url(doc.getUrl(), source, duplicateSources)) { // Other files, if the file already exists then update it (essentially, delete/add) doc.setUpdateId(qr.getLastDuplicateId()); // (set _id to doc we're going to replace) docsToUpdate.add(doc); } else { // if duplicateSources is non-empty then this URL is a duplicate of one from a different source if (!duplicateSources.isEmpty()) { doc.setDuplicateFrom(duplicateSources.getFirst()); } docsToAdd.add(doc); } } catch (Exception e) { errors++; _context.getHarvestStatus() .logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); } } } catch (Exception e) { // If an exception here this is catastrophic, throw it upwards: errors++; throw e; } }
From source file:net.spfbl.spf.SPF.java
/** * Merge nas listas de fixao de SPF.//w ww . j a v a 2s . co m * * @param midleList lista dos mecanismos centrais. * @param errorList lista dos mecanismos com erro de sintaxe. */ private static void mergeMechanism(LinkedList<String> midleList, LinkedList<String> errorList) { while (!errorList.isEmpty()) { boolean fixed = false; if (errorList.size() > 1) { for (int index = 1; index < errorList.size(); index++) { String tokenFix = errorList.getFirst(); for (String tokenError : errorList.subList(1, index + 1)) { tokenFix += tokenError; } if (isMechanismMiddle(tokenFix)) { midleList.add(tokenFix); int k = 0; while (k++ <= index) { errorList.removeFirst(); } fixed = true; break; } } } if (!fixed) { // No foi capaz de corrigir o erro. midleList.add(errorList.removeFirst()); } } }
From source file:net.firejack.platform.core.store.AbstractStore.java
@SuppressWarnings("unchecked") protected Criterion parseAdvancedSearchRequest(List<SearchQuery> searchQueries, Map<String, String> aliases, boolean skipNotValidValues) { int index = 0; LinkedList<Criterion> criterions = new LinkedList<Criterion>(); for (SearchQuery searchQuery : searchQueries) { Criterion criterion;/*ww w . j av a 2 s.co m*/ String field = searchQuery.getField(); if (field == null) { criterions.add(Restrictions.sqlRestriction("1 = 1")); } else { String[] fieldNames = field.split("\\."); if (fieldNames.length == 1) { String fieldName = fieldNames[0]; PropertyDescriptor propertyDescriptor = ClassUtils.getPropertyDescriptor(getClazz(), fieldName); if (propertyDescriptor != null) { Method readMethod = propertyDescriptor.getReadMethod(); if (readMethod != null) { Class<?> returnType = readMethod.getReturnType(); try { criterion = getRestrictions(searchQuery, returnType); criterions.add(criterion); } catch (IllegalArgumentException e) { if (!skipNotValidValues) { throw new BusinessFunctionException( "The field '" + fieldName + "' has type '" + returnType.getName() + "', but value '" + searchQuery.getValue() + "' is incorrect"); } } } else { throw new BusinessFunctionException("The field '" + fieldName + "' has not read method in class '" + getClazz().getName() + "'"); } } else { throw new BusinessFunctionException("The field '" + fieldName + "' does not exist in class '" + getClazz().getName() + "'"); } } else { Class<E> aClass = getClazz(); String indexedFieldName = null; for (int i = 0; i < fieldNames.length; i++) { String fieldName = fieldNames[i]; PropertyDescriptor propertyDescriptor = ClassUtils.getPropertyDescriptor(aClass, fieldName); if (propertyDescriptor != null) { Method readMethod = propertyDescriptor.getReadMethod(); if (readMethod != null) { Class<?> returnType = readMethod.getReturnType(); if (Collection.class.isAssignableFrom(returnType)) { returnType = (Class<?>) ((ParameterizedTypeImpl) readMethod .getGenericReturnType()).getActualTypeArguments()[0]; } if (AbstractModel.class.isAssignableFrom(returnType)) { aClass = (Class) returnType; String alias = i == 0 ? fieldName : indexedFieldName + "." + fieldName; indexedFieldName = aliases.get(alias); if (indexedFieldName == null) { indexedFieldName = fieldName + index++; aliases.put(alias, indexedFieldName); } } else { if (i == (fieldNames.length - 1)) { String queryFieldName = indexedFieldName + "." + fieldName; try { criterion = getRestrictions(new SearchQuery(queryFieldName, searchQuery.getOperation(), searchQuery.getValue()), returnType); criterions.add(criterion); } catch (IllegalArgumentException e) { if (!skipNotValidValues) { throw new BusinessFunctionException("The field '" + fieldName + "' has type '" + returnType.getName() + "', but value '" + searchQuery.getValue() + "' is incorrect"); } } } else { throw new BusinessFunctionException("Field name: '" + fieldName + "' is not correct in query: '" + field + "'"); } } } else { throw new BusinessFunctionException("The field '" + fieldName + "' has not read method in class '" + aClass + "'"); } } else { throw new BusinessFunctionException( "The field '" + fieldName + "' does not exist in class '" + aClass + "'"); } } } } } Criterion andCriterion = null; for (Criterion criterion : criterions) { andCriterion = criterions.getFirst() == criterion ? criterion : Restrictions.and(andCriterion, criterion); } return andCriterion; }