public ElementDescriptor getChildByName(String childName) { Collection<ElementDescriptor> values = childs.get(childName); return CollectionUtils.isEmpty(values) ? null : values.iterator().next(); }
private ConfigurationDeclaration findMatchingConfiguration(Declaration declaration, final TypeElement configurationElement) { return (ConfigurationDeclaration) CollectionUtils.find(declaration.getConfigurations(), new Predicate() { @Override public boolean evaluate(Object object) { Configuration configuration = configurationElement.getAnnotation(Configuration.class); ConfigurationDeclaration configurationDeclaration = (ConfigurationDeclaration) object; return configurationDeclaration.getName().equals(configuration.name()); } }); } }
private <T extends Artifact> Collection getArtifactsToRedeploy(Collection<T> collection) { return CollectionUtils.select(collection, new Predicate() { @Override public boolean evaluate(Object object) { return ((Artifact) object).getDescriptor().isRedeploymentEnabled(); } }); }
/** * Calls {@link #toString(Collection, int, boolean)} with <code>false</code> * for newline. */ public static String toString(Collection c, int maxElements) { return toString(c, maxElements, false); }
public MessageReceiver[] getReceivers(String wildcardExpression) { WildcardFilter filter = new WildcardFilter(wildcardExpression); filter.setCaseSensitive(false); List<MessageReceiver> found = new ArrayList<>(); for (Map.Entry<Object, MessageReceiver> e : receivers.entrySet()) { if (filter.accept(e.getKey())) { found.add(e.getValue()); } } return CollectionUtils.toArrayOfComponentType(found, MessageReceiver.class); }
@Override public boolean isUpdatedZombieArtifact(String artifactName) { @SuppressWarnings("rawtypes") Collection<String> deployedAppNames = CollectionUtils.collect(artifacts, new BeanToPropertyValueTransformer(ARTIFACT_NAME_PROPERTY)); if (deployedAppNames.contains(artifactName) && (!artifactZombieMap.containsKey(artifactName))) { return false; } ZombieFile zombieFile = artifactZombieMap.get(artifactName); if ((zombieFile != null) && (!zombieFile.updatedZombieApp())) { return false; } return true; }
/** * Creates a String representation of the given Collection, with optional * newlines between elements. Class objects are represented by their full names. * * @param c the Collection to format * @param newline indicates whether elements are to be split across lines * @return the formatted String */ public static String toString(Collection c, boolean newline) { if (c == null || c.isEmpty()) { return "[]"; } return toString(c, c.size(), newline); }
protected String[] getProperties(Schedule schedule) throws MuleException { List<String> props = new ArrayList<String>(2); if (StringUtils.isNotBlank(schedule.cron())) { props.add(QuartzConnector.PROPERTY_CRON_EXPRESSION + "=" + schedule.cron()); } else if (schedule.interval() > -1) { props.add(QuartzConnector.PROPERTY_REPEAT_INTERVAL + "=" + schedule.interval()); if (schedule.startDelay() > -1) { props.add(QuartzConnector.PROPERTY_START_DELAY +"=" + schedule.startDelay()); } } else { throw new IllegalArgumentException("cron or repeatInterval must be set"); } return CollectionUtils.toArrayOfComponentType(props, String.class); }
payload = CollectionUtils.collect((Collection) payload, new Transformer()
public static File findFileByName(File folder, final String filename, boolean recursive) { Collection<File> files = findFiles(folder, new IOFileFilter() { @Override public boolean accept(File file) { return filename.equals(file.getName()); } @Override public boolean accept(File dir, String name) { return true; } }, true); return CollectionUtils.isEmpty(files) ? null : files.iterator().next(); } }
public <T extends Artifact> T findArtifact(String artifactName, ObservableList<T> artifacts) { return (T) CollectionUtils.find(artifacts, new BeanPropertyValueEqualsPredicate(ARTIFACT_NAME_PROPERTY, artifactName)); }
public Collection<?> select(Predicate predicate) { Lock readLock = registryLock.readLock(); try { readLock.lock(); return CollectionUtils.select(registry.values(), predicate); } finally { readLock.unlock(); } }
protected MuleDefinitionParser getDelegate(Element element, ParserContext parserContext) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); ++i) { String attribute = SpringXMLUtils.attributeName((Attr) attributes.item(i)); if (attributeToParserIndex.containsKey(attribute)) { return getDelegate(((Integer) attributeToParserIndex.get(attribute)).intValue()); } } throw new IllegalArgumentException("Element " + SpringXMLUtils.elementToString(element) + " does not contain any attribute from " + CollectionUtils.toString(attributeToParserIndex.keySet(), 10, false)); }
public static File findFileByName(File folder, final String filename, boolean recursive) { Collection<File> files = FileUtils.findFiles(folder, new IOFileFilter() { @Override public boolean accept(File file) { return filename.equals(file.getName()); } @Override public boolean accept(File dir, String name) { return true; } }, true); return CollectionUtils.isEmpty(files) ? null : files.iterator().next(); } }
private T findArtifact(String artifactName) { return (T) CollectionUtils.find(artifacts, new BeanPropertyValueEqualsPredicate(ARTIFACT_NAME_PROPERTY, artifactName)); }
List<MuleEvent> nonNullResults = (List<MuleEvent>) CollectionUtils.select(results, new Predicate()
return CollectionUtils.toString((Collection<?>) o, MAX_ELEMENTS);
public static Field getField(Class<?> clazz, String name, Class<?> type) { Collection<Field> candidates = getAllFields(clazz, withName(name), withTypeAssignableTo(type)); return CollectionUtils.isEmpty(candidates) ? null : candidates.iterator().next(); }
Object commitOrRollback = CollectionUtils.find(entries, new Predicate()
ts = CollectionUtils.select(ts, new Predicate()