List of usage examples for java.util List contains
boolean contains(Object o);
From source file:com.evolveum.midpoint.schema.util.PolicyRuleTypeUtil.java
@SuppressWarnings("unchecked") private static void resolveLocalReferences(PolicyConstraintsType pc, ConstraintResolver resolver) throws ObjectNotFoundException, SchemaException { for (PolicyConstraintReferenceType ref : pc.getRef()) { String refName = ref != null ? ref.getName() : null; if (StringUtils.isEmpty(refName)) { throw new SchemaException("Illegal empty reference: " + ref); }/* www. ja v a 2 s. c o m*/ List<String> pathToRoot = getPathToRoot(pc); if (pathToRoot.contains(refName)) { throw new SchemaException("Trying to resolve cyclic reference to constraint '" + refName + "'. Contained in: " + pathToRoot); } JAXBElement<? extends AbstractPolicyConstraintType> resolved = resolver.resolve(refName); QName constraintName = resolved.getName(); AbstractPolicyConstraintType constraintValue = resolved.getValue(); PrismContainer<? extends AbstractPolicyConstraintType> container = pc.asPrismContainerValue() .findOrCreateContainer(constraintName); container.add(constraintValue.asPrismContainerValue().clone()); } pc.getRef().clear(); }
From source file:ffx.potential.parameters.PolarizeType.java
/** * A recursive method that checks all atoms bonded to the seed atom for * inclusion in the polarization group. The method is called on each newly * found group member./*from w ww . j a va 2 s .co m*/ * * @param polarizationGroup Atom types that should be included in the group. * @param group XYZ indeces of current group members. * @param seed The bonds of the seed atom are queried for inclusion in the * group. */ private static void growGroup(List<Integer> polarizationGroup, List<Integer> group, Atom seed) { List<Bond> bonds = seed.getBonds(); for (Bond bi : bonds) { Atom aj = bi.get1_2(seed); int tj = aj.getType(); boolean added = false; for (int g : polarizationGroup) { if (g == tj) { Integer index = aj.getXYZIndex() - 1; if (!group.contains(index)) { group.add(index); added = true; break; } } } if (added) { PolarizeType polarizeType = aj.getPolarizeType(); for (int i : polarizeType.polarizationGroup) { if (!polarizationGroup.contains(i)) { polarizationGroup.add(i); } } growGroup(polarizationGroup, group, aj); } } }
From source file:com.wavemaker.common.util.IOUtils.java
/** * Copy from: file to file, directory to directory, file to directory. * /*w w w .j a v a 2s.co m*/ * @param source File object representing a file or directory to copy from. * @param destination File object representing the target; can only represent a file if the source is a file. * @param excludes A list of exclusion filenames. * @throws IOException */ public static void copy(File source, File destination, List<String> excludes) throws IOException { if (!source.exists()) { throw new IOException("Can't copy from non-existent file: " + source.getAbsolutePath()); } else if (excludes.contains(source.getName())) { return; } if (source.isDirectory()) { if (!destination.exists()) { FileUtils.forceMkdir(destination); } if (!destination.isDirectory()) { throw new IOException("Can't copy directory (" + source.getAbsolutePath() + ") to non-directory: " + destination.getAbsolutePath()); } File files[] = source.listFiles(new java.io.FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.indexOf("#") == -1 && name.indexOf("~") == -1; } }); for (int i = 0; i < files.length; i++) { copy(files[i], new File(destination, files[i].getName()), excludes); } } else if (source.isFile()) { if (destination.isDirectory()) { destination = new File(destination, source.getName()); } InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(destination); copy(in, out); in.close(); out.close(); } else { throw new IOException( "Don't know how to copy " + source.getAbsolutePath() + "; it's neither a directory nor a file"); } }
From source file:org.topbraid.jenax.util.ARQFactory.java
/** * Gets a list of named graphs (GRAPH elements) mentioned in a given * Query.//from www. j a v a 2 s. c o m * @param query the Query to traverse * @return a List of those GRAPHs */ public static List<String> getNamedGraphURIs(Query query) { final List<String> results = new LinkedList<String>(); ElementWalker.walk(query.getQueryPattern(), new ElementVisitorBase() { @Override public void visit(ElementNamedGraph el) { Node node = el.getGraphNameNode(); if (node != null && node.isURI()) { String uri = node.getURI(); if (!results.contains(uri)) { results.add(uri); } } } }); return results; }
From source file:bridge.toolkit.commands.PreProcess.java
/** * Adds ICN references from referenced data modules to the list of files * to be used as dependencies in the resources section. * //from w w w. j a v a 2 s .c om * @param dependencies - List of Strings that will be used as "Dependency" elements for "SCO" resources. * @param dmDoc - Document object that represents the data module file being used. * @throws JDOMException */ private static List<String> addICNDependencies(List<String> dependencies, Document dmDoc) throws JDOMException { // reach into the dm docs and find ICN references List<String> icnRefs = searchForICN(dmDoc); Iterator<String> icn_iter = icnRefs.iterator(); while (icn_iter.hasNext()) { String the_icn = icn_iter.next(); if (!dependencies.contains(the_icn)) { dependencies.add(the_icn); } } return dependencies; }
From source file:com.headswilllol.basiclauncher.Launcher.java
public static void checkFile(File dir, File file, List<String> allowed) { if (file.isDirectory()) { if (!allowed.contains(file.getPath().replace(dir.getPath() + File.separator, ""))) for (File f : file.listFiles()) checkFile(dir, f, allowed); } else if (!allowed.contains(file.getPath().replace(dir.getPath() + File.separator, ""))) file.delete();//from ww w . java 2 s . c om }
From source file:edu.byu.nlp.dataset.BasicSparseFeatureVector.java
public static BasicSparseFeatureVector fromDenseFeatureVector(double[] denseVector) { List<Integer> indices = Lists.newArrayList(); List<Double> values = Lists.newArrayList(); for (int i = 0; i < denseVector.length; i++) { if (denseVector[i] != 0) { indices.add(i);/* w w w . j a v a 2s . c o m*/ values.add(denseVector[i]); } } // preserve length info by adding the extreme index with value 0 (if necessary) if (!indices.contains(denseVector.length - 1)) { indices.add(denseVector.length - 1); values.add(0.0); } return new BasicSparseFeatureVector(IntArrays.fromList(indices), DoubleArrays.fromList(values)); }
From source file:net.roboconf.target.docker.internal.DockerUtils.java
/** * Finds a container by ID or by name.//from ww w . jav a 2s . c om * @param name the container ID or name (not null) * @param dockerClient a Docker client * @return a container, or null if none was found */ public static Container findContainerByIdOrByName(String name, DockerClient dockerClient) { Container result = null; List<Container> containers = dockerClient.listContainersCmd().withShowAll(true).exec(); for (Container container : containers) { List<String> names = Arrays.asList(container.getNames()); // Docker containers are prefixed with '/'. // At least, those we created, since their parent is the Docker daemon. if (container.getId().equals(name) || names.contains("/" + name)) { result = container; break; } } return result; }
From source file:br.ufpr.inf.opla.patterns.util.AdapterUtil.java
public static Class getAdapterClass(Element target, Element adaptee) { Class adapterClass = null;/*from w ww . j a v a 2s .c o m*/ List<Element> allTargetSubElements = ElementUtil.getAllSubElements(target); List<Element> allAdapteeSuperElements = ElementUtil.getAllSuperElements(adaptee); rootFor: for (Element element : allTargetSubElements) { if (element instanceof Class && !((Class) element).isAbstract()) { List<Relationship> elementRelationships = ElementUtil.getRelationships(element); for (Relationship relationship : elementRelationships) { Element usedElementFromRelationship = RelationshipUtil .getUsedElementFromRelationship(relationship); if (usedElementFromRelationship != null && (usedElementFromRelationship.equals(adaptee) || allAdapteeSuperElements.contains(usedElementFromRelationship))) { adapterClass = (Class) element; break rootFor; } } } } if (adapterClass == null) { Architecture architecture = ArchitectureRepository.getCurrentArchitecture(); List<Class> classByName = architecture.findClassByName(adaptee.getName() + "Adapter"); if (classByName != null) { adapterClass = classByName.get(0); } } return adapterClass; }