Package org.apache.commons.collections

Examples of org.apache.commons.collections.Predicate


        return getBeans(metadata, BEAN_STATE_LESS);
    }

    public Collection getBeans(final Collection metadata, final int beanType) {
        return CollectionUtils.select(metadata,
            new Predicate() {
                public boolean evaluate(Object meta) {
                    JavaClass javaClass = (JavaClass) meta;
                    return hasFlag(getBeanType(javaClass), beanType);
                }
            });
View Full Code Here


        }

        // Select all public abstract methods started by "ejbSelect" with a non-void
        // return type
        return CollectionUtils.select(Arrays.asList(clazz.getMethods(true)),
            new Predicate() {
                public boolean evaluate(Object object) {
                    JavaMethod method = (JavaMethod) object;
                    int methodType = getMethodType(method);
                    boolean retVal = hasFlag(methodType, IFACE_METHOD_SELECT);
                    retVal = retVal && method.isAbstract();
View Full Code Here

    }

    public Collection getInterfaceMethods(final JavaClass clazz, final int viewType) {
        return
                CollectionUtils.select(Arrays.asList(clazz.getMethods(true)),
                        new Predicate() {
                            public boolean evaluate(Object object) {
                                JavaMethod method = (JavaMethod) object;
                                boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method),
                                        EjbUtils.IFACE_METHOD_COMPONENT);
                                retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, clazz), viewType);
View Full Code Here

        return method;
    }

    public Collection getCreateMethods(final JavaClass javaClass, final int viewType, final Type newType) {
        Collection createMethods = CollectionUtils.select(Arrays.asList(javaClass.getMethods(true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_CREATE);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, javaClass), viewType);
                        return retVal;
View Full Code Here

        return createMethods;
    }

    public Collection getHomeMethods(final JavaClass clazz, final int viewType) {
        Collection homeMethods = CollectionUtils.select(Arrays.asList(clazz.getMethods(true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_HOME);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, clazz), viewType);
                        return retVal;
View Full Code Here

        }

        // NOTE: xdoclet-1.2.3 makes reference to method-level
        // ejb.finder (it's not supported, as it's inconsistent across code base)
        Collection finderMethods = CollectionUtils.select(Arrays.asList(javaClass.getMethods(true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_FINDER);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, javaClass), viewType);
                        return retVal;
                    }
                });

        // Let's remove the "ejb" from it's name
        finderMethods = CollectionUtils.collect(finderMethods,
                new Transformer() {
                    public Object transform(Object object) {
                        return ejbUtils.externalizeMethodName((JavaMethod) object);

                        // return ejbUtils.removeFromMethodName((JavaMethod) object, "ejb");
                    }
                });

        Collection finderMethodsBySignature = CollectionUtils.select(Arrays.asList(javaClass.getTagsByName(
                    TagLibrary.EJB_FINDER, true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        EjbFinderTag finderTag = (EjbFinderTag) object;
                        boolean retVal = finderTag.getResultTypeMapping() == null ||
                            finderTag.getResultTypeMapping().equals(EjbUtils.REMOTE_INTERFACE);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(finderTag.getViewType()), viewType);
                        return retVal;
                    }
                });

        finderMethods.addAll(CollectionUtils.collect(finderMethodsBySignature,
                new Transformer() {
                public Object transform(Object object) {
                    EjbFinderTag finderTag = (EjbFinderTag) object;
                    return ejbUtils.getFinderMethodBySignature(finderTag.getSignature());
                }
            }));

        // Add mandatory findByPrimaryKey if not already there
        // Is this only for CMP ?? (xdoclet-1.2.3 says so, but i'll ignore
        // it for consistency, but it has a point anyway..
        // TODO: Centralize "findByPrimaryKey" /EjbPkTag somewhere..
        // if (ejbUtils.isCMP(javaClass)) {
        // Let's check if there is at least one "findByPrimaryKey"
        int count = CollectionUtils.countMatches(finderMethods,
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        return "findByPrimaryKey".equals(method.getName());
                    }
                });
View Full Code Here

            return (ValueObjectRelationMetadata[]) relationLst.toArray(new ValueObjectRelationMetadata[0]);
        }

        public ValueObjectRelationMetadata[] getCollectionRelations() {
            Collection relations = CollectionUtils.select(relationLst,
                    new Predicate() {
                        public boolean evaluate(Object arg0) {
                            ValueObjectRelationMetadata relation = (ValueObjectRelationMetadata) arg0;
                            return relation.isCollection();
                        }
                    });
View Full Code Here

            return (ValueObjectRelationMetadata[]) relations.toArray(new ValueObjectRelationMetadata[0]);
        }

        public ValueObjectRelationMetadata[] getNonCollectionRelations() {
            Collection relations = CollectionUtils.select(relationLst,
                    new Predicate() {
                        public boolean evaluate(Object arg0) {
                            ValueObjectRelationMetadata relation = (ValueObjectRelationMetadata) arg0;
                            return !relation.isCollection();
                        }
                    });
View Full Code Here

            return (ValueObjectFieldMetadata[]) fieldLst.toArray(new ValueObjectFieldMetadata[0]);
        }

        public ValueObjectFieldMetadata[] getPkFields() {
            Collection fields = CollectionUtils.select(fieldLst,
                    new Predicate() {
                        public boolean evaluate(Object arg0) {
                            ValueObjectFieldMetadata field = (ValueObjectFieldMetadata) arg0;
                            return field.isPrimaryKeyField();
                        }
                    });
View Full Code Here

            return (ValueObjectFieldMetadata[]) fields.toArray(new ValueObjectFieldMetadata[0]);
        }

        public ValueObjectFieldMetadata[] getNonPkFields() {
            Collection fields = CollectionUtils.select(fieldLst,
                    new Predicate() {
                        public boolean evaluate(Object arg0) {
                            ValueObjectFieldMetadata field = (ValueObjectFieldMetadata) arg0;
                            return !field.isPrimaryKeyField();
                        }
                    });
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.Predicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.