// Dumb brute force with memoization private Map.Entry<List<Integer>, List<Integer>> bestSplit( List<Integer> left, List<Integer> right, Map<String, Map.Entry<List<Integer>, List<Integer>>> mem) { if (mem.containsKey(getKey(left, right))) { return mem.get(getKey(left, right)); } if (Math.abs(left.size() - right.size()) <= 1) { AbstractMap.SimpleEntry<List<Integer>, List<Integer>> entry = new AbstractMap.SimpleEntry<>(left, right); mem.put(getKey(left, right), entry); return entry; } int minDifference = Integer.MAX_VALUE; Map.Entry<List<Integer>, List<Integer>> minEntry = null; for (int i = 0; i < right.size(); i++) { ArrayList<Integer> newLeft = new ArrayList<>(left); newLeft.add(right.get(i)); ArrayList<Integer> newRight = new ArrayList<>(right); newRight.remove(i); Map.Entry<List<Integer>, List<Integer>> entry = bestSplit(newLeft, newRight, mem); int difference = getDifference(entry); if (difference < minDifference) { minDifference = difference; minEntry = entry; } } return minEntry; }
/** * A childless stran is a "problem" in general because they break the evenness of the tree There * are three types of such strands, extra nodes to the left, extra to the right, or extra in * between parents. This method places those strands in spot. * * @param childlessStrand - the childless node to be laid out. * @param parentLeft - the nearest parent on the left (or <value>null</value> if none such exists) * @param parentRight - the nearest parent on the right (or <value>null</value> if none such * exists) * @param yLoc - the vertical location to lay out the nodes on. */ private void placeChildless( List<GXMoreThanNode> childlessStrand, GXMoreThanNode parentLeft, GXMoreThanNode parentRight, int yLoc) { int startMark = 0; int spacing = (int) (childlessStrand.get(0).getNode().getLayoutEntity().getWidthInLayout() + horSpacing); // There's only a parent on the right if (parentLeft == null && parentRight != null) { startMark = parentRight.getX() - (spacing * childlessStrand.size()); } // there's a parent on the left else if (parentLeft != null) { startMark = parentLeft.getX() + spacing; // there's a parent on the right as well meaning the childless are between two parents // we need to make there's enough room to place them if (parentRight != null) { int endMark = startMark + (spacing * childlessStrand.size()); // if there isn't enough room to place the childless between the parents if (endMark > parentRight.getX()) { // shift everything on the right to the right by the missing amount of space. shiftTreesRightOfMark(parentRight, endMark - parentRight.getX()); } } } // now the room has been assured, place strand. placeStrand(childlessStrand, startMark, yLoc, spacing); }
@NotNull public static char[] adaptiveLoadText(@NotNull Reader reader) throws IOException { char[] chars = new char[4096]; List<char[]> buffers = null; int count = 0; int total = 0; while (true) { int n = reader.read(chars, count, chars.length - count); if (n <= 0) break; count += n; if (total > 1024 * 1024 * 10) throw new FileTooBigException("File too big " + reader); total += n; if (count == chars.length) { if (buffers == null) { buffers = new ArrayList<char[]>(); } buffers.add(chars); int newLength = Math.min(1024 * 1024, chars.length * 2); chars = new char[newLength]; count = 0; } } char[] result = new char[total]; if (buffers != null) { for (char[] buffer : buffers) { System.arraycopy(buffer, 0, result, result.length - total, buffer.length); total -= buffer.length; } } System.arraycopy(chars, 0, result, result.length - total, total); return result; }
public static List<List<Integer>> levelOrderBottom(TreeNode root) { if (root == null) { return new ArrayList<>(); } List<List<Integer>> res = new ArrayList<>(); List<Integer> level = new ArrayList<>(); Queue<TreeNode> queue = new LinkedList<>(); // 新建一个queue,用来记录哪些nodes是目前的波前 queue.add(root); // 向root注水作为波前 queue.add(null); // 在波前队列queue加null作为Flag代表这层level已访问结束 while (queue.size() != 0) { TreeNode u = queue.poll(); if (u != null) { level.add(u.val); /* * 波前u向其所有有连同的node扩散 * u是v的predecessor前驱 or parent * v是u的 descendent后记 * */ if (u.left != null) { queue.add(u.left); } if (u.right != null) { queue.add(u.right); } } else { res.add(level); level = new ArrayList<Integer>(); if (!queue.isEmpty()) { queue.add(null); } } } Collections.reverse(res); return res; }
/** * @description: Lzw encodes the supplied input * @method encode * @param {string} s * @param {function} callback */ public static List<Integer> encode(String input) { // Build the dictionary. int dictSize = 256; Map<String, Integer> dictionary = new HashMap<String, Integer>(); for (int i = 0; i < 256; i++) { dictionary.put("" + (char) i, i); } String w = ""; List<Integer> result = new ArrayList<Integer>(); for (char c : input.toCharArray()) { String wc = w + c; if (dictionary.containsKey(wc)) { w = wc; } else { result.add(dictionary.get(w)); // Add wc to the dictionary. dictionary.put(wc, dictSize++); w = "" + c; } } // Output the code for w. if (!w.equals("")) { result.add(dictionary.get(w)); } return result; }
/* * Returns list of sensors currently loaded in the system * */ public static String getListOfSensors() { StringBuilder s = new StringBuilder(); Iterator iter = Mappings.getAllVSensorConfigs(); sensors.clear(); coordinates.clear(); while (iter.hasNext()) { VSensorConfig sensorConfig = (VSensorConfig) iter.next(); Double longitude = sensorConfig.getLongitude(); Double latitude = sensorConfig.getLatitude(); Double altitude = sensorConfig.getAltitude(); String sensor = sensorConfig.getName(); if ((latitude != null) && (longitude != null) && (altitude != null)) { Point point = new Point(latitude, longitude, altitude); coordinates.add(point); sensors.add(sensor); s.append(sensor) .append(" => ") .append(longitude) .append(" : ") .append(latitude) .append("\n"); } } return s.toString(); }
/** * @param mailId * @return HashMap<String, List<EmailPojo>> * @throws Exception */ private HashMap<String, List<EmailPojo>> sortByMailbox(String mailId) { HashMap<String, List<EmailPojo>> hashMapMail = new HashMap<String, List<EmailPojo>>(); for (String tempId : mailId.split(",+")) { try { IEMailSentService emailSentService = new EmailSentService(); EmailPojo emailPojo = emailSentService.getEmailPojo(tempId); List<EmailPojo> tempList; if ("9".equals(emailPojo.getEmail().getStatus())) { SenderConfig.initLocalSMTPConfig(emailPojo.getAccount()); if (hashMapMail.containsKey("localsmtp")) { hashMapMail.get("localsmtp").add(emailPojo); } else { tempList = new ArrayList<EmailPojo>(); tempList.add(emailPojo); hashMapMail.put("localsmtp", tempList); } } else { SenderConfig.initAccount(emailPojo.getAccount()); if (hashMapMail.containsKey(emailPojo.getAccount().getName())) { hashMapMail.get(emailPojo.getAccount().getName()).add(emailPojo); } else { tempList = new ArrayList<EmailPojo>(); tempList.add(emailPojo); hashMapMail.put(emailPojo.getAccount().getName(), tempList); } } } catch (Exception e) { log.error("sortByMailbox/SendMailListener/Exception: [lose mailID] [" + tempId + "]", e); } } return hashMapMail; }
/** * This is for debug only: print out training matrices in a CSV type format so that the matrices * can be examined in a spreadsheet program for debugging purposes. */ private void WriteCSVfile( List<String> rowNames, List<String> colNames, float[][] buf, String fileName) { p("tagList.size()=" + tagList.size()); try { FileWriter fw = new FileWriter(fileName + ".txt"); PrintWriter bw = new PrintWriter(new BufferedWriter(fw)); // write the first title row: StringBuffer sb = new StringBuffer(500); for (int i = 0, size = colNames.size(); i < size; i++) { sb.append("," + colNames.get(i)); } bw.println(sb.toString()); // loop on remaining rows: for (int i = 0, size = buf.length; i < size; i++) { sb.delete(0, sb.length()); sb.append(rowNames.get(i)); for (int j = 0, size2 = buf[i].length; j < size2; j++) { sb.append("," + buf[i][j]); } bw.println(sb.toString()); } bw.close(); } catch (IOException ioe) { ioe.printStackTrace(); } }
public String oneCookie(String name) { Cookie found = null; List<Cookie> allFound = null; for (Cookie cookie : getCookies()) { if (cookie.name().equals(name)) { if (found == null) { found = cookie; } else if (allFound == null) { allFound = new ArrayList<>(2); allFound.add(found); } else { allFound.add(cookie); } } } if (found == null) { return null; } else if (allFound != null) { StringBuilder s = new StringBuilder("Multiple cookies with name '").append(name).append("': "); int i = 0; for (Cookie cookie : allFound) { s.append(cookie.toString()); if (++i < allFound.size()) { s.append(", "); } } throw new IllegalStateException(s.toString()); } else { return found.value(); } }
/** @param config */ public DecorateHandler(TagConfig config) { super(config); this.template = this.getRequiredAttribute("template"); this.handlers = new HashMap(); Iterator itr = this.findNextByType(DefineHandler.class); DefineHandler d = null; while (itr.hasNext()) { d = (DefineHandler) itr.next(); this.handlers.put(d.getName(), d); if (log.isLoggable(Level.FINE)) { log.fine(tag + " found Define[" + d.getName() + "]"); } } List paramC = new ArrayList(); itr = this.findNextByType(ParamHandler.class); while (itr.hasNext()) { paramC.add(itr.next()); } if (paramC.size() > 0) { this.params = new ParamHandler[paramC.size()]; for (int i = 0; i < this.params.length; i++) { this.params[i] = (ParamHandler) paramC.get(i); } } else { this.params = null; } }
/** * This is for book production only: print out training matrices in a Latex type format so that * the matrices can be inserted into my manuscript: * * <p>\begin{table}[htdp] \caption{Runtimes by Method} \centering * * <p>\begin{tabular}{|l|l|l|} \hline \textbf{Class.method name}&\textbf{Percent of total * runtime}&\textbf{Percent in this method}\\ \hline Chess.main&97.7&0.0\\ * GameSearch.playGame&96.5&0.0\\ * * <p>Chess.calcPieceMoves&1.7&0.8\\ \hline \end{tabular} * * <p>\label{tab:runtimes_by_method} \end{table} */ private void WriteLatexFile( List<String> rowNames, List<String> colNames, float[][] buf, String fileName) { p("tagList.size()=" + tagList.size()); int SKIP = 6; try { FileWriter fw = new FileWriter(fileName + ".latex"); PrintWriter bw = new PrintWriter(new BufferedWriter(fw)); int size = colNames.size() - SKIP; bw.print("\\begin{table*}[htdp]\n\\caption{ADD CAPTION}\\centering\\begin{tabular}{|"); for (int i = 0; i < size + 1; i++) bw.print("l|"); bw.println("}\n\\hline"); bw.print(" &"); for (int i = 0; i < size; i++) { bw.print("\\emph{" + colNames.get(i) + "}"); if (i < (size - 1)) bw.print("&"); } bw.println("\\\\\n\\hline"); // bw.printf(format, args) // loop on remaining rows: for (int i = 0, size3 = buf.length - SKIP; i < size3; i++) { bw.print(rowNames.get(i) + "&"); for (int j = 0, size2 = buf[i].length - SKIP; j < size2; j++) { bw.printf("%.2f", buf[i][j]); if (j < (size2 - 1)) bw.print("&"); } bw.println("\\\\"); } bw.println("\\hline\n\\end{tabular}\n\\label{tab:CHANGE_THIS_LABEL}\n\\end{table*}"); bw.close(); } catch (IOException ioe) { ioe.printStackTrace(); } }
/** * Builds the matrix of nodes. each node will be wrapped with necessary innformation such as who * are the direct children and parent (only visually in the graph not the actual relationships) * the returned matrix is organized more or less as the real tree. * * @param entitiesList - entities to place in the matrix * @param relationshipsList - the relationships between the entities given * @return the matrix - (a list of rows of nodes) */ private List<List<GXMoreThanNode>> buildNodeMatrix( List<InternalNode> entitiesList, List<InternalRelationship> relationshipsList) { List<List<GXMoreThanNode>> rows = new ArrayList<List<GXMoreThanNode>>(); while (!entitiesList.isEmpty()) { InternalNode root = getFirstEntity(entitiesList, relationshipsList); // add root row if necessary if (rows.isEmpty()) { rows.add(new ArrayList<GXMoreThanNode>()); rows.add(new ArrayList<GXMoreThanNode>()); } // lay out the current root node and remove it from the list of entities left entitiesList.remove(root); GXMoreThanNode moreThanRoot = new GXMoreThanNode(root, null); rows.get(0).add(moreThanRoot); // build the tree that spreads from this current root. builtTreeFromRoot(moreThanRoot, entitiesList, relationshipsList, rows.get(1), rows); } trimEmptyRows(rows); return rows; }
@Test public void testCreateAndDropManyDatabases() throws Exception { List<String> createdDatabases = new ArrayList<>(); InfoSchemaMetadataDictionary dictionary = new InfoSchemaMetadataDictionary(); String namePrefix = "database_"; final int NUM = 10; for (int i = 0; i < NUM; i++) { String databaseName = namePrefix + i; assertFalse(catalog.existDatabase(databaseName)); catalog.createDatabase(databaseName, TajoConstants.DEFAULT_TABLESPACE_NAME); assertTrue(catalog.existDatabase(databaseName)); createdDatabases.add(databaseName); } Collection<String> allDatabaseNames = catalog.getAllDatabaseNames(); for (String databaseName : allDatabaseNames) { assertTrue( databaseName.equals(DEFAULT_DATABASE_NAME) || createdDatabases.contains(databaseName) || dictionary.isSystemDatabase(databaseName)); } // additional ones are 'default' and 'system' databases. assertEquals(NUM + 2, allDatabaseNames.size()); Collections.shuffle(createdDatabases); for (String tobeDropped : createdDatabases) { assertTrue(catalog.existDatabase(tobeDropped)); catalog.dropDatabase(tobeDropped); assertFalse(catalog.existDatabase(tobeDropped)); } }
@Override public List<BluetoothDwell> getBluetoothDwellInRangeByCampaign( Date start, Date end, Company c, Campaign camp) { Query q; if (start == null || end == null) { q = em.createQuery( "SELECT bdwell FROM BluetoothDwell bdwell WHERE bdwell.company = ?1 and bdwell.campaign = ?2"); q.setParameter(1, c); q.setParameter(2, camp); } else { q = em.createQuery( "SELECT bdwell FROM BluetoothDwell bdwell WHERE bdwell.company = ?1 AND bdwell.eventDate BETWEEN ?2 AND ?3 AND bdwell.campaign = ?4"); q.setParameter(1, c); q.setParameter(2, start, TemporalType.TIMESTAMP); q.setParameter(3, end, TemporalType.TIMESTAMP); q.setParameter(4, camp); } List<BluetoothDwell> results = (List<BluetoothDwell>) q.getResultList(); if (results.size() > 0) { return results; } return null; }
@Override public BluetoothDaySummary fetchBluetoothDaySummary( Date eventDate, Company company, Campaign campaign, Device device) { String query = "SELECT b FROM BluetoothDaySummary b WHERE b.eventDate BETWEEN ?1 AND ?2 AND b.company = ?3 "; int paramCount = 3; HashMap<Integer, Object> params = new HashMap<Integer, Object>(); if (campaign != null) { paramCount++; query += " AND b.campaign = ?" + paramCount + " "; params.put(paramCount, campaign); } if (device != null) { paramCount++; query += " AND b.device = ?" + paramCount + " "; params.put(paramCount, device); } Query q = em.createQuery(query); q.setParameter(1, eventDate); q.setParameter(2, DateUtil.getEndOfDay(eventDate)); q.setParameter(3, company); for (Map.Entry<Integer, Object> entry : params.entrySet()) { Integer paramId = entry.getKey(); Object object = entry.getValue(); q.setParameter(paramId, object); } List<BluetoothDaySummary> results = (List<BluetoothDaySummary>) q.getResultList(); if (results.size() > 0) { return results.get(0); } return null; }
public void addTypeArgument(Access node) { List<Access> list = (parent == null || state == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList(); list.addChild(node); }
private List<TypeSymbol> resolveInterfaces( final JavacNode annotationNode, final Class<? extends java.lang.annotation.Annotation> annotationType, final List<Object> listenerInterfaces) { List<TypeSymbol> resolvedInterfaces = new ArrayList<TypeSymbol>(); for (Object listenerInterface : listenerInterfaces) { if (listenerInterface instanceof JCFieldAccess) { JCFieldAccess interfaze = (JCFieldAccess) listenerInterface; if ("class".equals(As.string(interfaze.name))) { Type interfaceType = CLASS.resolveMember(annotationNode, interfaze.selected); if (interfaceType == null) continue; if (interfaceType.isInterface()) { TypeSymbol interfaceSymbol = interfaceType.asElement(); if (interfaceSymbol != null) resolvedInterfaces.add(interfaceSymbol); } else { annotationNode.addWarning( String.format( "@%s works only with interfaces. %s was skipped", annotationType.getName(), listenerInterface)); } } } } return resolvedInterfaces; }
@Override public void handle( final AnnotationValues<ListenerSupport> annotation, final JCAnnotation source, final JavacNode annotationNode) { deleteAnnotationIfNeccessary(annotationNode, ListenerSupport.class); JavacType type = JavacType.typeOf(annotationNode, source); if (type.isAnnotation() || type.isInterface()) { annotationNode.addError(canBeUsedOnClassAndEnumOnly(ListenerSupport.class)); return; } List<Object> listenerInterfaces = annotation.getActualExpressions("value"); if (listenerInterfaces.isEmpty()) { annotationNode.addError( String.format( "@%s has no effect since no interface types were specified.", ListenerSupport.class.getName())); return; } List<TypeSymbol> resolvedInterfaces = resolveInterfaces(annotationNode, ListenerSupport.class, listenerInterfaces); for (TypeSymbol interfaze : resolvedInterfaces) { handler.addListenerField(type, interfaze); handler.addAddListenerMethod(type, interfaze); handler.addRemoveListenerMethod(type, interfaze); addFireListenerMethods(type, interfaze); } type.editor().rebuild(); }
public boolean checkUserInput()//TicketReservationClient userInput) { //Valid calls/commands List<String> validCalls = Arrays.asList("RESERVE", "BOOKSEAT", "SEARCH", "DELETE"); //make sure it's one of the valid calls if (!validCalls.contains(call))//userInput.call)) { return false; } //make sure every call has the name parameter if ( name == null) { return false; } //seatnum cannot be null/0 for bookseat if (call.compareTo("BOOKSEAT") == 0 && seatNum == -1) { return false; } //make there's no additional param for the following calls if ((call.compareTo("RESERVE") == 0 || call.compareTo("SEARCH") == 0 || call.compareTo("DELETE") == 0) && seatNum != -1) { return false; } return true; }
@NotNull public static byte[] adaptiveLoadBytes(@NotNull InputStream stream) throws IOException { byte[] bytes = new byte[4096]; List<byte[]> buffers = null; int count = 0; int total = 0; while (true) { int n = stream.read(bytes, count, bytes.length - count); if (n <= 0) break; count += n; if (total > 1024 * 1024 * 10) throw new FileTooBigException("File too big " + stream); total += n; if (count == bytes.length) { if (buffers == null) { buffers = new ArrayList<byte[]>(); } buffers.add(bytes); int newLength = Math.min(1024 * 1024, bytes.length * 2); bytes = new byte[newLength]; count = 0; } } byte[] result = new byte[total]; if (buffers != null) { for (byte[] buffer : buffers) { System.arraycopy(buffer, 0, result, result.length - total, buffer.length); total -= buffer.length; } } System.arraycopy(bytes, 0, result, result.length - total, total); return result; }
private void sendMaybeEmail(String to) { String subject = "Processing is taking a long time"; StringBuilder content = new StringBuilder(); content.append("Your process is taking longer than expected."); content.append(" It might finish in a bit, but here is the status so far"); content.append("\n\tUpload: ").append((uploadSuccessful) ? "success" : "waiting"); content.append("\n\tParse: ").append((netcdfSuccessful) ? "success" : "waiting"); content.append("\n\tStatistics: ").append((rStatsSuccessful) ? "success" : "waiting"); content.append("\n\tMetadata: ").append((cswTransSuccessful) ? "success" : "waiting"); content.append( "\n\nYou will receive another email if there is a success, but may not receive a failure notification."); List<String> bcc = new ArrayList<String>(); String from = props.getProperty("watersmart.email.from"); String bccAddr = props.getProperty("watersmart.email.tracker"); if (!"".equals(bccAddr)) { bcc.add(bccAddr); } EmailMessage message = new EmailMessage(from, to, null, bcc, subject, content.toString()); try { EmailHandler.sendMessage(message); } catch (AddressException ex) { log.error("Unable to send maybe e-mail:\n" + message, ex); } catch (MessagingException ex) { log.error("Unable to send maybe e-mail:\n" + message, ex); } }
/** * Utility method used in the construction of {@link UnitGraph}s, to be called only after the * unitToPreds and unitToSuccs maps have been built. * * <p><code>UnitGraph</code> provides an implementation of <code>buildHeadsAndTails()</code> which * defines the graph's set of heads to include the first {@link Unit} in the graph's body, * together with any other <tt>Unit</tt> which has no predecessors. It defines the graph's set of * tails to include all <tt>Unit</tt>s with no successors. Subclasses of <code>UnitGraph</code> * may override this method to change the criteria for classifying a node as a head or tail. */ protected void buildHeadsAndTails() { List tailList = new ArrayList(); List headList = new ArrayList(); for (Iterator unitIt = unitChain.iterator(); unitIt.hasNext(); ) { Unit s = (Unit) unitIt.next(); List succs = (List) unitToSuccs.get(s); if (succs.size() == 0) { tailList.add(s); } List preds = (List) unitToPreds.get(s); if (preds.size() == 0) { headList.add(s); } } // Add the first Unit, even if it is the target of // a branch. Unit entryPoint = (Unit) unitChain.getFirst(); if (!headList.contains(entryPoint)) { headList.add(entryPoint); } tails = Collections.unmodifiableList(tailList); heads = Collections.unmodifiableList(headList); }
public void testAsCollectionWithList() { List list = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); assertAsCollection(list, 3); }
@Nullable private static PyType getCallableType(@NotNull PsiElement resolved, @NotNull Context context) { if (resolved instanceof PySubscriptionExpression) { final PySubscriptionExpression subscriptionExpr = (PySubscriptionExpression) resolved; final PyExpression operand = subscriptionExpr.getOperand(); final Collection<String> operandNames = resolveToQualifiedNames(operand, context.getTypeContext()); if (operandNames.contains("typing.Callable")) { final PyExpression indexExpr = subscriptionExpr.getIndexExpression(); if (indexExpr instanceof PyTupleExpression) { final PyTupleExpression tupleExpr = (PyTupleExpression) indexExpr; final PyExpression[] elements = tupleExpr.getElements(); if (elements.length == 2) { final PyExpression parametersExpr = elements[0]; final PyExpression returnTypeExpr = elements[1]; if (parametersExpr instanceof PyListLiteralExpression) { final List<PyCallableParameter> parameters = new ArrayList<>(); final PyListLiteralExpression listExpr = (PyListLiteralExpression) parametersExpr; for (PyExpression argExpr : listExpr.getElements()) { parameters.add(new PyCallableParameterImpl(null, getType(argExpr, context))); } final PyType returnType = getType(returnTypeExpr, context); return new PyCallableTypeImpl(parameters, returnType); } if (isEllipsis(parametersExpr)) { return new PyCallableTypeImpl(null, getType(returnTypeExpr, context)); } } } } } return null; }
private static List<FunctionDescriptor> getSuperFunctionsForMethod( @NotNull PsiMethodWrapper method, @NotNull BindingTrace trace, @NotNull ClassDescriptor containingClass) { List<FunctionDescriptor> superFunctions = Lists.newArrayList(); Map<ClassDescriptor, JetType> superclassToSupertype = getSuperclassToSupertypeMap(containingClass); Multimap<FqName, Pair<FunctionDescriptor, PsiMethod>> superclassToFunctions = getSuperclassToFunctionsMultimap(method, trace.getBindingContext(), containingClass); for (HierarchicalMethodSignature superSignature : method.getPsiMethod().getHierarchicalMethodSignature().getSuperSignatures()) { PsiMethod superMethod = superSignature.getMethod(); PsiClass psiClass = superMethod.getContainingClass(); assert psiClass != null; String classFqNameString = psiClass.getQualifiedName(); assert classFqNameString != null; FqName classFqName = new FqName(classFqNameString); if (!JavaToKotlinClassMap.getInstance().mapPlatformClass(classFqName).isEmpty()) { for (FunctionDescriptor superFun : JavaToKotlinMethodMap.INSTANCE.getFunctions(superMethod, containingClass)) { superFunctions.add(substituteSuperFunction(superclassToSupertype, superFun)); } continue; } DeclarationDescriptor superFun = superMethod instanceof JetClsMethod ? trace.get( BindingContext.DECLARATION_TO_DESCRIPTOR, ((JetClsMethod) superMethod).getOrigin()) : findSuperFunction(superclassToFunctions.get(classFqName), superMethod); if (superFun == null) { reportCantFindSuperFunction(method); continue; } assert superFun instanceof FunctionDescriptor : superFun.getClass().getName(); superFunctions.add( substituteSuperFunction(superclassToSupertype, (FunctionDescriptor) superFun)); } // sorting for diagnostic stability Collections.sort( superFunctions, new Comparator<FunctionDescriptor>() { @Override public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) { FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration()); FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration()); return fqName1.getFqName().compareTo(fqName2.getFqName()); } }); return superFunctions; }
@Nullable private static PyType getParameterizedType( @NotNull PsiElement element, @NotNull Context context) { if (element instanceof PySubscriptionExpression) { final PySubscriptionExpression subscriptionExpr = (PySubscriptionExpression) element; final PyExpression operand = subscriptionExpr.getOperand(); final PyExpression indexExpr = subscriptionExpr.getIndexExpression(); final PyType operandType = getType(operand, context); if (operandType instanceof PyClassType) { final PyClass cls = ((PyClassType) operandType).getPyClass(); final List<PyType> indexTypes = getIndexTypes(subscriptionExpr, context); if (PyNames.TUPLE.equals(cls.getQualifiedName())) { if (indexExpr instanceof PyTupleExpression) { final PyExpression[] elements = ((PyTupleExpression) indexExpr).getElements(); if (elements.length == 2 && isEllipsis(elements[1])) { return PyTupleType.createHomogeneous(element, indexTypes.get(0)); } } return PyTupleType.create(element, indexTypes); } else if (indexExpr != null) { return new PyCollectionTypeImpl(cls, false, indexTypes); } } } return null; }
/** * @param localFlag * @return String */ private String sendMail(HashMap<String, List<EmailPojo>> hashMapMail, boolean localFlag) { String failrueId = null; String accountName = null; String getfailrueId; try { for (String key : hashMapMail.keySet()) { List<EmailPojo> mailPojoList = hashMapMail.get(key); Account account = mailPojoList.get(0).getAccount(); accountName = account.getName(); Operator operator; if (localFlag) { operator = (Operator) beanFactory.getBean("localsmtp"); } else { if (beanFactory.containsBean(account.getSendProtocolType())) { operator = (Operator) beanFactory.getBean(account.getSendProtocolType()); } else { operator = (Operator) beanFactory.getBean("localsmtp"); } } getfailrueId = operator.sendMail(mailPojoList); if (failrueId == null) { if (getfailrueId != null) { failrueId = getfailrueId; } } else { if (getfailrueId != null) { failrueId += "," + getfailrueId; } } } } catch (Exception e) { log.error("sendMail/SendMailListener/Exception: " + "[" + accountName + "]", e); } return failrueId; }
private List<ReportParameter> mapParams(Map<String, Set<String>> parameters) { List<ReportParameter> params = new ArrayList<>(parameters.size()); for (Map.Entry<String, Set<String>> entry : parameters.entrySet()) { params.add(new ReportParameter(entry.getKey(), entry.getValue())); } return params; }
private List<Block> toBlockList(Collection<BlockVector> locs) { List<Block> blocks = new ArrayList<>(locs.size()); for (BlockVector location : locs) blocks.add( world.getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ())); return blocks; }
/** * @return hash code of the instance * @author Klaus Meffert * @since 2.3 */ public int hashCode() { if (m_data.size() == 0) { return -29; } else { return m_data.hashCode(); } }