List of usage examples for org.apache.commons.collections.functors InstanceofPredicate InstanceofPredicate
public InstanceofPredicate(Class type)
From source file:com.architexa.diagrams.relo.parts.ReloController.java
@SuppressWarnings("unchecked") public List<ArtifactRelEditPart> getVisibleArtifactRelEditParts() { List allChildren = new LinkedList(getViewer().getEditPartRegistry().values()); CollectionUtils.filter(allChildren, new InstanceofPredicate(ArtifactRelEditPart.class)); return allChildren; }
From source file:com.architexa.diagrams.relo.parts.ReloController.java
@SuppressWarnings("unchecked") public List<ArtifactEditPart> getVisibleArtifactEditParts() { List allChildren = new LinkedList(getViewer().getEditPartRegistry().values()); CollectionUtils.filter(allChildren, new InstanceofPredicate(ArtifactEditPart.class)); return allChildren; }
From source file:org.apache.stanbol.enhancer.nlp.model.impl.SectionImpl.java
/** * Internal helper to generate correctly generic typed {@link Iterator}s for * filtered {@link Span} types/* w ww .j a va2 s .c o m*/ * @param interfaze the Span interface e.g. {@link Token} * @param clazz the actual Span implementation e.g. {@link TokenImpl} * @return the {@link Iterator} of type {interface} iterating over * {implementation} instances (e.g. * <code>{@link Iterator}<{@link Token}></code> returning * <code>{@link TokenImpl}</code> instances on calls to {@link Iterator#next()} */ @SuppressWarnings("unchecked") protected <T extends Span> Iterator<T> filter(final Class<T> clazz) { return IteratorUtils.filteredIterator(getIterator(), new InstanceofPredicate(clazz)); }
From source file:org.dentaku.gentaku.cartridge.entity.hibernate.HibernateEntityGenerator.java
protected Collection setupClasses(CorePackage core, Stereotype classifierStereotype, UmlPackage entityPackage, ClassifierImpl odspEntity, org.omg.uml.UmlPackage umlPackage) throws GenerationException { Collection extendedElements = new LinkedList( core.getAStereotypeExtendedElement().getExtendedElement(classifierStereotype)); // pass 1: set up the classes and do the fields while we are here for (Iterator elemIterator = extendedElements.iterator(); elemIterator.hasNext();) { ModelElementImpl modelElement = (ModelElementImpl) elemIterator.next(); if (!(modelElement instanceof UmlClass)) { throw new GenerationException( "modelElement must be a UmlClass (is a " + modelElement.getClass().getName() + ")"); }/* ww w . jav a 2 s . c om*/ ClassifierImpl classifier = (ClassifierImpl) modelElement; Utils.createTaggedValue(core, classifier, findTagdef(entityPackage.getOwnedElement(), "inheritance.strategy"), "new-table"); Utils.createTaggedValue(core, classifier, findTagdef(entityPackage.getOwnedElement(), "discriminator.strategy"), "class-name"); Utils.createTaggedValue(core, classifier, findTagdef(entityPackage.getOwnedElement(), "column.name"), "java_type"); createGeneralization(core, odspEntity, classifier); // update our superclass structure to accurately reflect what we are generating String entityName = classifier.getName(); classifier.setName(entityName + "Base"); ClassifierImpl subclass = (ClassifierImpl) Utils.findUmlClass(umlPackage, ((ModelElementImpl) classifier.getNamespace()).getFullyQualifiedName(), entityName, true); subclass.getStereotype().add(classifierStereotype); Utils.createTaggedValue(core, subclass, findTagdef(entityPackage.getOwnedElement(), "class.name"), "${parent.name}"); Utils.createTaggedValue(core, subclass, findTagdef(entityPackage.getOwnedElement(), "class.persistence-capable-superclass"), ((ModelElementImpl) classifier).getFullyQualifiedName()); Utils.createTaggedValue(core, subclass, "gentaku.generate", "false"); Utils.createTaggedValue(core, subclass, findTagdef(entityPackage.getOwnedElement(), "inheritance.strategy"), "superclass-table"); // handle the fields Collection attributes = CollectionUtils.select(classifier.getFeature(), new InstanceofPredicate(Attribute.class)); for (Iterator attIterator = attributes.iterator(); attIterator.hasNext();) { Attribute attribute = (Attribute) attIterator.next(); TaggedValue taggedValue = Utils.createTaggedValue(core, attribute, findTagdef(entityPackage.getOwnedElement(), "field.name"), "${parent.name}"); attribute.getTaggedValue().add(taggedValue); } // move the relations down to the subclass Collection links = new LinkedList(classifier.getAssociationLinks()); for (Iterator moveIterator = links.iterator(); moveIterator.hasNext();) { AssociationEnd associationEnd = (AssociationEnd) moveIterator.next(); associationEnd.setParticipant(subclass); } } return extendedElements; }
From source file:org.mule.registry.TransientRegistry.java
@SuppressWarnings("unchecked") public <T> Collection<T> lookupObjects(Class<T> returntype) { return (Collection<T>) registryMap.select(new InstanceofPredicate(returntype)); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getAttributes() { return CollectionUtils.select(getFeature(), new InstanceofPredicate(Attribute.class)); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getOperations() { return CollectionUtils.select(getFeature(), new InstanceofPredicate(Operation.class)); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getAbstractions() { // todo there's gotta be a better way to do this than iterating the list three times... Collection clientDependencies = getCore().getAClientClientDependency().getClientDependency(this); Collection collection = CollectionUtils.select(clientDependencies, new InstanceofPredicate(Abstraction.class)); return CollectionUtils.collect(collection, new Transformer() { public Object transform(Object object) { return ((Abstraction) object).getSupplier().iterator().next(); }//from w ww. j av a 2 s . co m }); }
From source file:org.openconcerto.sql.model.Where.java
/** * To create complex Where not possible with constructors. * // w w w. j a v a 2 s . com * @param pattern a pattern to be passed to {@link SQLSelect#quote(String, Object...)}, eg * "EXTRACT(YEAR FROM %n) = 3007". * @param params the params to be passed to <code>quote()</code>, eg [|MISSION.DATE_DBT|]. * @return a new Where with the result from <code>quote()</code> as its clause, and all * <code>FieldRef</code> in params as its fields, eg {EXTRACT(YEAR FROM "DATE_DBT") = * 3007 , |MISSION.DATE_DBT|}. */ @SuppressWarnings("unchecked") static public Where quote(String pattern, Object... params) { return new Where(SQLSelect.quote(pattern, params), org.apache.commons.collections.CollectionUtils .select(Arrays.asList(params), new InstanceofPredicate(FieldRef.class))); }