List of usage examples for java.util List contains
boolean contains(Object o);
From source file:io.appium.uiautomator2.utils.ElementHelpers.java
/** * Remove all duplicate elements from the provided list * * @param elements - elements to remove duplicates from * * @return a new list with duplicates removed *///from w ww . ja v a 2 s.c o m public static List<Object> dedupe(List<Object> elements) { try { findAccessibilityNodeInfo = method(UiObject.class, "findAccessibilityNodeInfo", long.class); } catch (Exception e) { e.printStackTrace(); } List<Object> result = new ArrayList<Object>(); List<AccessibilityNodeInfo> nodes = new ArrayList<AccessibilityNodeInfo>(); for (Object element : elements) { AccessibilityNodeInfo node = elementToNode(element); if (!nodes.contains(node)) { nodes.add(node); result.add(element); } } return result; }
From source file:br.on.daed.services.pdf.DadosMagneticos.java
public static byte[] gerarPDF(String ano, String tipo) throws IOException, InterruptedException, UnsupportedOperationException { File tmpFolder;//from w w w .j a v a2 s . com String folderName; Double anoDouble = Double.parseDouble(ano); List<String> dados = Arrays.asList(TIPO_DADOS_MAGNETICOS); byte[] ret = null; if (anoDouble >= ANO_MAGNETICO[0] && anoDouble < ANO_MAGNETICO[1] && dados.contains(tipo)) { do { folderName = "/tmp/dislin" + Double.toString(System.currentTimeMillis() * Math.random()); tmpFolder = new File(folderName); } while (tmpFolder.exists()); tmpFolder.mkdir(); ProcessBuilder processBuilder = new ProcessBuilder("/opt/declinacao-magnetica/./gerar", ano, tipo); processBuilder.directory(tmpFolder); processBuilder.environment().put("LD_LIBRARY_PATH", "/usr/local/dislin"); Process proc = processBuilder.start(); proc.waitFor(); ProcessHelper.outputProcess(proc); File arquivoServido = new File(folderName + "/dislin.pdf"); FileInputStream fis = new FileInputStream(arquivoServido); ret = IOUtils.toByteArray(fis); processBuilder = new ProcessBuilder("rm", "-r", folderName); tmpFolder = new File("/"); processBuilder.directory(tmpFolder); Process delete = processBuilder.start(); delete.waitFor(); } else { throw new UnsupportedOperationException("Entrada invlida"); } return ret; }
From source file:Main.java
public static List<Element> getElementsByTagNames(Element element, String[] tagNames) { List<Element> children = new ArrayList<Element>(); if (element != null && tagNames != null) { List tagList = Arrays.asList(tagNames); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && tagList.contains(((Element) child).getTagName())) { children.add((Element) child); }/*from w ww . j a v a2s . co m*/ } } return children; }
From source file:Main.java
/** * Tabu refresh./* ww w . j a v a 2s . c o m*/ * @param map * @param tabu * @return map/tabu */ private static Map<Integer, Integer> tabuRefresh(Map<Integer, Integer> map, List<Integer> tabu) { Map<Integer, Integer> mapCopy = new HashMap<Integer, Integer>(); for (Map.Entry<Integer, Integer> e : map.entrySet()) { Integer key = e.getKey(); Integer value = e.getValue(); if (!tabu.contains(key.intValue())) { mapCopy.put(key, value); } } return mapCopy; }
From source file:de.tor.tribes.util.TribeUtils.java
public static Tribe[] getTribeByVillage(Village[] pVillages, boolean pUseBarbarians, Comparator<Tribe> pComparator) { List<Tribe> tribes = new LinkedList<>(); for (Village v : pVillages) { Tribe t = v.getTribe();// w w w .j a v a2 s . c o m if (pUseBarbarians || !t.equals(Barbarians.getSingleton())) { if (!tribes.contains(t)) { tribes.add(t); } } } if (pComparator != null) { Collections.sort(tribes, pComparator); } return tribes.toArray(new Tribe[tribes.size()]); }
From source file:Main.java
/** * Build schema location map of schemas used in given * <code>schemaLocationAttribute</code> and adds them to the given * <code>schemaLocationMap</code>. * //from w w w . j av a2 s. c o m * @see <a href="http://www.w3.org/TR/xmlschema-0/#schemaLocation">XML Schema * Part 0: Primer Second Edition | 5.6 schemaLocation</a> * * @param schemaLocationMap * {@link Map} to add schema locations to. * @param schemaLocation * attribute value to build schema location map from. * @return {@link Map} of schema namespace URIs to location URLs. * @since 8.1 */ static final Map<String, List<String>> buildSchemaLocationMap(Map<String, List<String>> schemaLocationMap, final String schemaLocation) { if (null == schemaLocation) { return schemaLocationMap; } if (null == schemaLocation || schemaLocation.isEmpty()) { // should really ever be null but being safe. return schemaLocationMap; } final StringTokenizer st = new StringTokenizer(schemaLocation, " \n\t\r"); while (st.hasMoreElements()) { final String ns = st.nextToken(); final String loc = st.nextToken(); List<String> locs = schemaLocationMap.get(ns); if (null == locs) { locs = new ArrayList<>(); schemaLocationMap.put(ns, locs); } if (!locs.contains(loc)) { locs.add(loc); } } return schemaLocationMap; }
From source file:ddf.catalog.transformer.metacard.propertyjson.PropertyJsonMetacardTransformer.java
@Nullable private static Object convertAttribute(Attribute attribute, AttributeDescriptor descriptor, List<AttributeType.AttributeFormat> dontInclude) throws CatalogTransformerException { if (dontInclude.contains(descriptor.getType().getAttributeFormat())) { return null; }//from www.j a v a2s . c o m if (descriptor.isMultiValued()) { List<Object> values = new ArrayList<>(); for (Serializable value : attribute.getValues()) { values.add(convertValue(attribute.getName(), value, descriptor.getType().getAttributeFormat())); } return values; } else { return convertValue(attribute.getName(), attribute.getValue(), descriptor.getType().getAttributeFormat()); } }
From source file:Main.java
@NonNull public static <T> List<T> nonIntersection(List<T> list1, List<T> list2) { if (list1 == null) { list1 = new ArrayList<>(); }/*from w w w . j ava 2s . com*/ if (list2 == null) { list2 = new ArrayList<>(); } List<T> list = new ArrayList<>(); for (T t : list1) { if (!list2.contains(t)) { list.add(t); } } return list; }
From source file:com.khartec.waltz.service.data_flow.RatedDataFlowService.java
/** * (dao, [ouId], [app]) -> [ dataFlow ] * <br>//from w w w .ja va2 s . c o m * @return a list of data flows where the target is a member of [app]. */ private static List<DataFlow> loadRelevantDataFlows(DataFlowDao dataFlowDao, List<Application> targetApps) { List<Long> appIds = toIds(targetApps); List<DataFlow> dataFlows = dataFlowDao.findByApplicationIds(appIds); return filter(df -> appIds.contains(df.target().id()), dataFlows); }
From source file:io.fabric8.maven.core.config.ProcessorConfig.java
private static List<String> removeDups(List<String> list) { List<String> ret = new ArrayList<>(); for (String el : list) { if (!ret.contains(el)) { ret.add(el);/*from w ww . j a v a 2s . c o m*/ } } return ret; }