Java 类org.apache.commons.collections.Predicate 实例源码

项目:aws-codecommit-trigger-plugin    文件:StringUtilsTest.java   
@Test
@SuppressWarnings("unchecked")
public void testSelects() {
    Record r = new Record();
    r.setUserIdentityARN("arn:sample");
    List<Record> records = Arrays.asList(r, new Record());
    Collection<Record> sample = CollectionUtils.select(records, new Predicate() {
        @Override
        public boolean evaluate(Object o) {
            return o instanceof Record && ((Record) o).getUserIdentityARN() != null &&  ((Record) o).getUserIdentityARN().contains("sample");
        }
    });

    Assertions.assertThat(sample).hasSize(1);
}
项目:apache-archiva    文件:FileTypes.java   
/**
 * Get the list of patterns for a specified filetype.
 * You will always get a list.  In this order.
 * <ul>
 * <li>The Configured List</li>
 * <li>The Default List</li>
 * <li>A single item list of <code>&quot;**&#47;*&quot;</code></li>
 * </ul>
 *
 * @param id the id to lookup.
 * @return the list of patterns.
 */
public List<String> getFileTypePatterns( String id )
{
    Configuration config = archivaConfiguration.getConfiguration();
    Predicate selectedFiletype = new FiletypeSelectionPredicate( id );
    RepositoryScanningConfiguration repositoryScanningConfiguration = config.getRepositoryScanning();
    if ( repositoryScanningConfiguration != null )
    {
        FileType filetype =
            (FileType) CollectionUtils.find( config.getRepositoryScanning().getFileTypes(), selectedFiletype );

        if ( ( filetype != null ) && CollectionUtils.isNotEmpty( filetype.getPatterns() ) )
        {
            return filetype.getPatterns();
        }
    }
    List<String> defaultPatterns = defaultTypeMap.get( id );

    if ( CollectionUtils.isEmpty( defaultPatterns ) )
    {
        return Collections.singletonList( "**/*" );
    }

    return defaultPatterns;
}
项目:my-paper    文件:Cart.java   
/**
 * 获取赠品项
 * 
 * @return 赠品项
 */
@Transient
public Set<GiftItem> getGiftItems() {
    Set<GiftItem> giftItems = new HashSet<GiftItem>();
    for (Promotion promotion : getPromotions()) {
        if (promotion.getGiftItems() != null) {
            for (final GiftItem giftItem : promotion.getGiftItems()) {
                GiftItem target = (GiftItem) CollectionUtils.find(giftItems, new Predicate() {
                    public boolean evaluate(Object object) {
                        GiftItem other = (GiftItem) object;
                        return other != null && other.getGift().equals(giftItem.getGift());
                    }
                });
                if (target != null) {
                    target.setQuantity(target.getQuantity() + giftItem.getQuantity());
                } else {
                    giftItems.add(giftItem);
                }
            }
        }
    }
    return giftItems;
}
项目:linkbinder    文件:CorresponGroupServiceImpl.java   
/**
 * ユーザーが同一プロジェクトに属していない場合はエラー.
 * @param users ユーザー
 * @throws ServiceAbortException 同一プロジェクトに属していない
 */
private void validateUserProjectDiff(List<User> users) throws ServiceAbortException {
    String projectId = getCurrentProjectId();
    SearchUserCondition condition = new SearchUserCondition();
    condition.setProjectId(projectId);
    List<ProjectUser> projectUsers = findProjectUser(condition);
    for (final User u : users) {
        //  プロジェクトに所属するユーザーリストに登録対象ユーザーが存在しなければエラー
        Object ret = CollectionUtils.find(projectUsers, new Predicate() {
            public boolean evaluate(Object object) {
                ProjectUser pu = (ProjectUser) object;
                return u.getEmpNo().equals(pu.getUser().getEmpNo());
            }
        });

        if (ret == null) {
            throw new ServiceAbortException(
                "invalid user",
                ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_USER_ALREADY_DELETED,
                u.getLabel());
        }
    }
}
项目:linkbinder    文件:CompanyServiceImpl.java   
/**
 * 選択されたプロジェクトユーザーのユーザーが同一プロジェクトに属しているかチェックする.
 * @param id ID
 * @param users ユーザーリスト
 * @throws ServiceAbortException プロジェクトに属していない
 */
private void validateProjectUserExists(Long id, List<User> users) throws ServiceAbortException {
    SearchUserCondition condition = new SearchUserCondition();
    condition.setProjectId(getCurrentProjectId());

    UserDao dao = getDao(UserDao.class);
    List<ProjectUser> projectUsers = dao.findProjectUser(condition);

    for (final User u : users) {
        //  プロジェクトに所属するユーザーリストに登録対象ユーザーが存在しなければエラー
        Object ret = CollectionUtils.find(projectUsers, new Predicate() {
            public boolean evaluate(Object object) {
                ProjectUser pu = (ProjectUser) object;
                return u.getEmpNo().equals(pu.getUser().getEmpNo());
            }
        });

        if (ret == null) {
            throw new ServiceAbortException(
                "invalid user",
                ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_USER_ALREADY_DELETED,
                u.getLabel());
        }
    }
}
项目:java-platform    文件:Cart.java   
/**
 * 获取赠品项
 * 
 * @return 赠品项
 */
@Transient
public Set<GiftItem> getGiftItems() {
    Set<GiftItem> giftItems = new HashSet<GiftItem>();
    for (Promotion promotion : getPromotions()) {
        if (promotion.getGiftItems() != null) {
            for (final GiftItem giftItem : promotion.getGiftItems()) {
                GiftItem target = (GiftItem) CollectionUtils.find(giftItems, new Predicate() {
                    public boolean evaluate(Object object) {
                        GiftItem other = (GiftItem) object;
                        return other != null && other.getGift().equals(giftItem.getGift());
                    }
                });
                if (target != null) {
                    target.setQuantity(target.getQuantity() + giftItem.getQuantity());
                } else {
                    giftItems.add(giftItem);
                }
            }
        }
    }
    return giftItems;
}
项目:AvatarMQ    文件:ConsumerContext.java   
public static int getClustersStat(String clusters) {

        Predicate predicate = new Predicate() {
            public boolean evaluate(Object object) {
                String clustersId = ((ClustersState) object).getClusters();
                return clustersId.compareTo(clusters) == 0;
            }
        };

        Iterator iterator = new FilterIterator(stateArray.iterator(), predicate);

        ClustersState state = null;
        while (iterator.hasNext()) {
            state = (ClustersState) iterator.next();
            break;

        }
        return (state != null) ? state.getState() : 0;
    }
项目:AvatarMQ    文件:ConsumerContext.java   
public static ConsumerClusters selectByClusters(String clusters) {
    Predicate predicate = new Predicate() {
        public boolean evaluate(Object object) {
            String id = ((ClustersRelation) object).getId();
            return id.compareTo(clusters) == 0;
        }
    };

    Iterator iterator = new FilterIterator(relationArray.iterator(), predicate);

    ClustersRelation relation = null;
    while (iterator.hasNext()) {
        relation = (ClustersRelation) iterator.next();
        break;
    }

    return (relation != null) ? relation.getClusters() : null;
}
项目:OpenCyclos    文件:CustomField.java   
public Collection<CustomFieldPossibleValue> getPossibleValuesByParent(final CustomFieldPossibleValue parentValue, final Boolean onlyEnabled) {
    // When this field has no parent, return all values
    if (parent == null) {
        return possibleValues;
    }

    // When there's no parent value, or it don't match this field's parent, return an empty list
    if (possibleValues == null || parentValue == null || !parent.equals(parentValue.getField())) {
        return Collections.emptyList();
    }

    // Filter the possible values by parent value
    final Collection<CustomFieldPossibleValue> filteredPossibleValues = new ArrayList<CustomFieldPossibleValue>(possibleValues);
    CollectionUtils.filter(filteredPossibleValues, new Predicate() {
        @Override
        public boolean evaluate(final Object object) {
            final CustomFieldPossibleValue possibleValue = (CustomFieldPossibleValue) object;
            return parentValue.equals(possibleValue.getParent()) && (onlyEnabled ? possibleValue.isEnabled() : true);
        }
    });
    return filteredPossibleValues;
}
项目:OpenCyclos    文件:ExportMembersTransactionsReportToCsvAction.java   
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<?> executeQuery(final ActionContext context) {
    final MembersReportHandler reportHandler = getReportHandler();
    final Pair<MembersTransactionsReportDTO, Iterator<MemberTransactionSummaryReportData>> pair = reportHandler.handleTransactionsSummary(context);
    final MembersTransactionsReportDTO dto = pair.getFirst();
    final Iterator<MemberTransactionSummaryReportData> reportIterator = pair.getSecond();
    final Iterator iterator = IteratorUtils.filteredIterator(reportIterator, new Predicate() {
        @Override
        public boolean evaluate(final Object element) {
            final MemberTransactionSummaryReportData data = (MemberTransactionSummaryReportData) element;
            if (dto.isIncludeNoTraders()) {
                return true;
            }
            return data.isHasData();
        }
    });
    return new IteratorListImpl(iterator);
}
项目:OpenCyclos    文件:ExportMembersTransactionsDetailsToCsvAction.java   
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<?> executeQuery(final ActionContext context) {
    final MembersReportHandler reportHandler = getReportHandler();
    final Pair<MembersTransactionsReportDTO, Iterator<MemberTransactionDetailsReportData>> pair = reportHandler.handleTransactionsDetails(context);
    final MembersTransactionsReportDTO dto = pair.getFirst();
    final Iterator<MemberTransactionDetailsReportData> reportIterator = pair.getSecond();
    final Iterator iterator = IteratorUtils.filteredIterator(reportIterator, new Predicate() {
        @Override
        public boolean evaluate(final Object element) {
            final MemberTransactionDetailsReportData data = (MemberTransactionDetailsReportData) element;
            if (dto.isIncludeNoTraders()) {
                return true;
            }
            return data.getAmount() != null;
        }
    });
    return new IteratorListImpl(iterator);
}
项目:dasein-cloud-azurepack    文件:AzurePackImageSupport.java   
@Nonnull
@Override
public Iterable<MachineImage> listImages(@Nullable final ImageFilterOptions options) throws CloudException, InternalException {
    if (options != null && !ImageClass.MACHINE.equals(options.getImageClass())) {
        return Collections.emptyList();
    }

    if(options != null)
        options.withAccountNumber(provider.getContext().getAccountNumber());

    return getImages(new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            if(options != null)
                return options.matches((MachineImage)object);
            else
                return provider.getContext().getAccountNumber().equals(((MachineImage)object).getProviderOwnerId());
        }
    });
}
项目:dasein-cloud-azurepack    文件:AzurePackNetworkSupport.java   
public void removeVlan(final String vlanId) throws CloudException, InternalException {
    WAPVMNetworksModel networksModel = new AzurePackRequester(provider,
            new AzurePackNetworkRequests(provider).listVMNetworks().build()).withJsonProcessor(WAPVMNetworksModel.class).execute();

    WAPVMNetworkModel foundNetwork = (WAPVMNetworkModel)CollectionUtils.find(networksModel.getVirtualMachineNetworks(), new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            return ((WAPVMNetworkModel)object).getId().equalsIgnoreCase(vlanId);
        }
    });

    if(foundNetwork == null)
        throw new InternalException("Invalid network id provided for deletion");

    new AzurePackRequester(provider, new AzurePackNetworkRequests(provider).deleteVMNetwork(foundNetwork).build()).execute();
}
项目:dasein-cloud-azurepack    文件:AzurePackDatabaseSupport.java   
private List<WAPDatabaseProducts.WAPDatabaseProduct> getDBProductsFromFile() throws InternalException {
    List<WAPDatabaseProducts> dbProducts = new ArrayList<>();
    try {
        InputStream inputStream = getDBProductFileStream(this.provider.getDBProductsResource());
        dbProducts.addAll(Arrays.asList(new JsonStreamToObjectProcessor<WAPDatabaseProducts[]>().read(inputStream, WAPDatabaseProducts[].class)));
    } catch (Exception ex) {
        throw new InternalException("Cannot load products from dbproducts.json file");
    }

    //if there is only one cloud provider in the json file, return all the products as default
    if(dbProducts.size() == 1)
        return Arrays.asList(dbProducts.get(0).getProducts());

    CollectionUtils.filter(dbProducts, new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            WAPDatabaseProducts products = (WAPDatabaseProducts)object;
            return provider.getContext().getCloud().getCloudName().equalsIgnoreCase(products.getCloud()) && provider.getContext().getCloud().getProviderName().equalsIgnoreCase(products.getProvider());
        }
    });

    if(dbProducts.size() != 1)
        return Arrays.asList();

    return Arrays.asList(dbProducts.get(0).getProducts());
}
项目:opencucina    文件:MapBasedSearchBeanMarshallManager.java   
private SearchCriterionMarshaller findMarshaller(final SearchCriterion criterion) {
    SearchCriterionMarshaller marshaller = cachedMarshallers.get(criterion.getClass());

    if (marshaller == null) {
        marshaller = (SearchCriterionMarshaller) CollectionUtils.find(marshallers,
                new Predicate() {
                    @Override
                    public boolean evaluate(Object arg0) {
                        SearchCriterionMarshaller marshaller = (SearchCriterionMarshaller) arg0;

                        return marshaller.supports(criterion.getClass());
                    }
                });
        // caching here for later use
        cachedMarshallers.put(criterion.getClass(), marshaller);
    }

    return marshaller;
}
项目:dasein-cloud-azurepack    文件:HttpMethodAsserts.java   
private static void assertHttpMethod(final HttpUriRequest actualHttpRequest, String expectedHttpMethod, String expectedUrl, Header[] expectedHeaders)
{
    assertHttpMethod(actualHttpRequest, expectedHttpMethod, expectedUrl);
    assertNotNull(actualHttpRequest.getAllHeaders());
    CollectionUtils.forAllDo(Arrays.asList(expectedHeaders), new Closure() {
        @Override
        public void execute(Object input) {
            final Header expectedHeader = (Header) input;
            boolean headerExists = CollectionUtils.exists(Arrays.asList(actualHttpRequest.getAllHeaders()), new Predicate() {
                @Override
                public boolean evaluate(Object object) {
                    Header actualHeader = (Header) object;
                    return expectedHeader.getName().equals(actualHeader.getName()) && expectedHeader.getValue().equals(actualHeader.getValue());
                }
            });
            assertTrue(String.format("Expected %s header not found in the request or found with the wrong value in the request", expectedHeader.getName()), headerExists);
        }
    });
}
项目:GOG    文件:MBManifestacao.java   
public void filtrarAreaSolucionadora() {
    unidades.clear();
    if(txtFiltroAreaSolucionadora.isEmpty()) {
        unidades.addAll(unidadesCompleta);
    } else {
        Predicate predicate = new Predicate() {
            @Override
            public boolean evaluate(Object obj) {
                TbUnidade u = (TbUnidade) obj;
                String nomeParaComparar = u.getSgUnidade().toLowerCase() + " - " + u.getNmUnidade().toLowerCase();
                return nomeParaComparar.contains(txtFiltroAreaSolucionadora.toLowerCase());
            }
        };
        CollectionUtils.select(unidadesCompleta, predicate, unidades);
    }
}
项目:mars-sim    文件:GraphWrapper.java   
/**
 *  Returns a wrapped traverser predicate, if necessary.
 */
protected Predicate wrapTraverserPredicate( Predicate traverserPredicate )
{
    if( traverserPredicate == null
        || traverserPredicate == FalsePredicate.INSTANCE
        || traverserPredicate == TruePredicate.INSTANCE
        || traverserPredicate == GraphUtils.OUT_TRAVERSER_PREDICATE
        || traverserPredicate == GraphUtils.IN_TRAVERSER_PREDICATE
        || traverserPredicate == GraphUtils.DIRECTED_TRAVERSER_PREDICATE
        || traverserPredicate == GraphUtils.UNDIRECTED_TRAVERSER_PREDICATE
        || traverserPredicate == GraphUtils.SELF_TRAVERSER_PREDICATE ) {
        return traverserPredicate;
    } else if( traverserPredicate instanceof EqualsTraverserPredicate ) {
        Graph.Edge wrapperEdge = ((EqualsTraverserPredicate) traverserPredicate).getTestEdge();
        return new EqualsTraverserPredicate( toDelegateEdge( wrapperEdge ) );
    } else if( traverserPredicate instanceof TraverserPredicate ) {
        TraverserPredicate predicate = (TraverserPredicate) traverserPredicate;
        return TraverserPredicateFactory.createPredicated( convertEdgeObjectSpec( predicate.getUserObjectSpecification() ),
                                                           convertNodeSpec( predicate.getNodeSpecification() ),
                                                           predicate.getDirectionFlags() );
    } else {
        return new TraverserPredicateWrapper( traverserPredicate );
    }
}
项目:GOG    文件:MBManifestacao.java   
public void filtrarClassificacao() {
    classificacoes.clear();
    if(txtFiltroClassificacao.isEmpty()) {
        classificacoes.addAll(classificacoesCompleta);
    } else {
        Predicate predicate = new Predicate() {
            @Override
            public boolean evaluate(Object obj) {
                TbClassificacao c = (TbClassificacao) obj;
                String nomeParaComparar = c.getDsClassificacao().toLowerCase();
                return nomeParaComparar.contains(txtFiltroClassificacao.toLowerCase());
            }
        };
        CollectionUtils.select(classificacoesCompleta, predicate, classificacoes);
    }
}
项目:Pinot    文件:PinotHelixResourceManager.java   
public List<String> getAllRealtimeTables() {
  List<String> ret = _helixAdmin.getResourcesInCluster(_helixClusterName);
  CollectionUtils.filter(ret, new Predicate() {
    @Override
    public boolean evaluate(Object object) {
      if (object == null) {
        return false;
      }
      if (object.toString().endsWith("_" + ServerType.REALTIME.toString())) {
        return true;
      }
      return false;
    }
  });
  return ret;
}
项目:dsworkbench    文件:DEPFilterTableModel.java   
public void addRow(final SupportSourceElement pElement, boolean pCheck) {

        Object result = CollectionUtils.find(elements, new Predicate() {

            @Override
            public boolean evaluate(Object o) {
                return ((SupportSourceElement) o).getVillage().equals(pElement.getVillage());
            }
        });

        if (result == null) {
            elements.add(pElement);
        }
        if (pCheck) {
            fireTableDataChanged();
        }
    }
项目:dsworkbench    文件:REFSourceTableModel.java   
public boolean removeRow(final Village pVillage, boolean pNotify) {

        REFSourceElement elem = (REFSourceElement) CollectionUtils.find(elements, new Predicate() {

            @Override
            public boolean evaluate(Object o) {
                return ((REFSourceElement) o).getVillage().equals(pVillage);
            }
        });

        if (elem != null) {
            elements.remove(elem);
        }

        if (pNotify) {
            fireTableDataChanged();
        }
        return elem != null;
    }
项目:adalid    文件:Writer.java   
private Predicate getPredicate(ExtendedProperties properties, List<Predicate> predicates, String keyPreffix) {
    String key = keyPreffix + ".predicate.join";
    String operator = properties.getString(key, "all");
    String[] operators = new String[]{"all", "any", "none", "one"};
    int i = ArrayUtils.indexOf(operators, operator.toLowerCase());
    switch (i) {
        case 1:
            return PredicateUtils.anyPredicate(predicates);
        case 2:
            return PredicateUtils.nonePredicate(predicates);
        case 3:
            return PredicateUtils.onePredicate(predicates);
        default:
            return PredicateUtils.allPredicate(predicates);
    }
}
项目:mars-sim    文件:AbstractGraph.java   
/**
 *  This implementation delegates to {@link #nodes() nodes()},
 *  except for when the specified <code>nodePredicate</code> is
 *  either {@link FalsePredicate#INSTANCE} or an instance of
 *  {@link EqualPredicate}.  These two cases are optimized.
 */
public Collection nodes( Predicate nodePredicate )
{
    if( nodePredicate == null || nodePredicate == TruePredicate.INSTANCE ) {
        return nodes();
    } else if( nodePredicate == FalsePredicate.INSTANCE ) {
        return Collections.EMPTY_SET;
    } else if( nodePredicate instanceof EqualPredicate ) {
        Object testNode = ((EqualPredicate) nodePredicate).getTestObject();
        if( !containsNode( testNode ) ) {
            return Collections.EMPTY_SET;
        }
        return new SingletonNodeCollection( this, testNode );
    } else {
        return new FilteredCollection( nodes(), nodePredicate );
    }
}
项目:mars-sim    文件:DefaultGraph.java   
public Collection adjacentNodes( Object node,
                                 Predicate traverserPredicate )
{
    if( LOGGER.isDebugEnabled() ) {
        LOGGER.debug( instanceString + ".adjacentNodes( "
                      + node + ", "
                      + traverserPredicate + " )" );
    }
    AdjacencyList adj = checkNode( node );
    CursorFilter filter = createCursorFilter( traverserPredicate );
    if( filter == FALSE_CURSOR_FILTER ) {
        if( LOGGER.isDebugEnabled() ) {
            LOGGER.debug( "  " + instanceString + ".adjacentNodes() returning empty set" );
        }
        return Collections.EMPTY_SET;
    }
    if( LOGGER.isDebugEnabled() ) {
        LOGGER.debug( "  " + instanceString + ".adjacentNodes() returning filtered collection" );
    }
    return new AdjNodeCollection( adj, filter );
}
项目:mars-sim    文件:DefaultGraph.java   
public Collection incidentEdges( Object node,
                                 Predicate traverserPredicate )
{
    if( LOGGER.isDebugEnabled() ) {
        LOGGER.debug( instanceString + ".incidentEdges( "
                      + node + ", "
                      + traverserPredicate + " )" );
    }
    AdjacencyList adj = checkNode( node );
    CursorFilter filter = createCursorFilter( traverserPredicate );
    if( filter == FALSE_CURSOR_FILTER ) {
        if( LOGGER.isDebugEnabled() ) {
            LOGGER.debug( "  " + instanceString + ".incidentEdges() returning empty set" );
        }
        return Collections.EMPTY_SET;
    }
    if( LOGGER.isDebugEnabled() ) {
        LOGGER.debug( "  " + instanceString + ".incidentEdges() returning filtered collection" );
    }
    return new IncEdgeCollection( adj, filter );
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPredicateReturnsInRange() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,1);
    TestRollbackableTask1 task = new TestRollbackableTask1(4);

    boolean result = patchRollbackPredicate.evaluate(task);
    assertTrue("PatchRollbackPredicate returned false unexpectedly",result);
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPredicateReturnsLessThanRollback() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,2);
    TestRollbackableTask1 task = new TestRollbackableTask1(1);

    boolean result = patchRollbackPredicate.evaluate(task);
    assertFalse("PatchRollbackPredicate returned true unexpectedly",result);
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPredicateReturnsGreaterThanCurrent() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,2);
    TestRollbackableTask1 task = new TestRollbackableTask1(11);

    boolean result = patchRollbackPredicate.evaluate(task);
    assertFalse("PatchRollbackPredicate returned true unexpectedly",result);
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPredicateReturnsLowerBoundary() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,2);
    TestRollbackableTask1 task = new TestRollbackableTask1(2);

    boolean result = patchRollbackPredicate.evaluate(task);
    assertFalse("PatchRollbackPredicate returned true unexpectedly",result);
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPredicateReturnsUpperBoundary() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,2);
    TestRollbackableTask1 task = new TestRollbackableTask1(10);

    boolean result = patchRollbackPredicate.evaluate(task);
    assertTrue("PatchRollbackPredicate returned false unexpectedly",result);
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPatchRollbackPredicateNull() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,2);

    boolean result = patchRollbackPredicate.evaluate(null);
    assertFalse("PatchRollbackPredicate returned true unexpectedly",result);
}
项目:lams    文件:PatchRollbackPredicateTest.java   
public void testPatchRollbackPredicateWrongClass() {

    //create a new predicate
    Predicate patchRollbackPredicate = new PatchRollbackPredicate(10,2);

    boolean result = patchRollbackPredicate.evaluate(new Object());
    assertFalse("testPatchRollbackPredicateWrongClass returned true unexpectedly",result);
}
项目:redirector    文件:SelectServer.java   
public IfExpression getRule(final String ruleId) {
    if (CollectionUtils.isEmpty(items)) {
        return null;
    }
    return (IfExpression)CollectionUtils.find(items, new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            return ((IfExpression)object).getId().equals(ruleId);
        }
    });
}
项目:redirector    文件:URLRules.java   
public IfExpression getUrlRule(final String ruleId) {
    if (CollectionUtils.isEmpty(items)) {
        return null;
    }
    return (IfExpression)CollectionUtils.find(items, new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            return ((IfExpression)object).getId().equals(ruleId);
        }
    });
}
项目:cuttlefish    文件:BipartiteVertexRenderer.java   
public void renderVertex(Graphics g, VisVertex vc)
    {
//      BipartiteVertex bpv = (BipartiteVertex) vc.getVertex();
//      Choice c = BipartiteGraph.CLASSA;
//      if (bpg != null)
//      {
//          c = bpg.getPartition(bpv);
//      }
//      StringLabeller sl = (c == BipartiteGraph.CLASSA) ? women : dates;
        Vertex bpv = (Vertex) vc.getVertex();
        Predicate part = BipartiteGraphReader.PART_A;
        if (bpg != null)
            part = BipartiteGraphReader.getPartition((Vertex) bpv.getEqualVertex(bpg));
        boolean in_a = part == (BipartiteGraphReader.PART_A);
        StringLabeller sl = in_a ? women : dates;
        String s = sl.getLabel((Vertex) bpv.getEqualVertex(bpg));

//      g.setColor((c == BipartiteGraph.CLASSA) ? Color.RED : Color.BLUE);
        g.setColor(in_a ? Color.RED : Color.BLUE);
        if (hiddenList != null && hiddenList.contains(s))
        {
            int x = (int) vc.getX();
            int y = (int) vc.getY();
            g.drawLine(x - 4, y - 4, x + 4, y + 4);
            g.drawLine(x + 4, y - 4, x - 4, y + 4);
        }
        else
            g.fillRect((int) vc.getX() - 4, (int) vc.getY() - 4, 8, 8);

        g.setColor(Color.black);
        g.drawString(s, (int) vc.getX() - 4, (int) vc.getY() + 16);
    }
项目:my-paper    文件:PluginServiceImpl.java   
public List<PaymentPlugin> getPaymentPlugins(final boolean isEnabled) {
    List<PaymentPlugin> result = new ArrayList<PaymentPlugin>();
    CollectionUtils.select(paymentPlugins, new Predicate() {
        public boolean evaluate(Object object) {
            PaymentPlugin paymentPlugin = (PaymentPlugin) object;
            return paymentPlugin.getIsEnabled() == isEnabled;
        }
    }, result);
    Collections.sort(result);
    return result;
}
项目:my-paper    文件:PluginServiceImpl.java   
public List<StoragePlugin> getStoragePlugins(final boolean isEnabled) {
    List<StoragePlugin> result = new ArrayList<StoragePlugin>();
    CollectionUtils.select(storagePlugins, new Predicate() {
        public boolean evaluate(Object object) {
            StoragePlugin storagePlugin = (StoragePlugin) object;
            return storagePlugin.getIsEnabled() == isEnabled;
        }
    }, result);
    Collections.sort(result);
    return result;
}
项目:gemfirexd-oss    文件:PlatformImplBase.java   
/**
     * Returns all identity properties whose value were defined by the database and which
     * now need to be read back from the DB.
     * 
     * @param model     The database model
     * @param dynaClass The dyna class
     * @param bean      The bean
     * @return The columns
     */
    private Column[] getRelevantIdentityColumns(Database model, SqlDynaClass dynaClass, final DynaBean bean)
    {
        SqlDynaProperty[] properties = dynaClass.getSqlDynaProperties();

        Collection relevantProperties = CollectionUtils.select(Arrays.asList(properties), new Predicate() {
            public boolean evaluate(Object input) {
                SqlDynaProperty prop = (SqlDynaProperty)input;

                // we only want those identity columns that were really specified by the DB
                // if the platform allows specification of values for identity columns
                // in INSERT/UPDATE statements, then we need to filter the corresponding
                // columns out
                return prop.getColumn().isAutoIncrement() &&
// GemStone changes BEGIN
                       // allow using ALTER TABLE for identity columns
                       // after initial data loading
                       (!isAddIdentityUsingAlterTableOn() ||
                           !getPlatformInfo()
                               .isAddingIdentityUsingAlterTableSupported()) &&
                       (!isIdentityOverrideOn() ||
                           !getPlatformInfo().isIdentityOverrideAllowed() ||
                           (bean.get(prop.getName()) == null));
                       /* (original code)
                       (!isIdentityOverrideOn() || !getPlatformInfo().isIdentityOverrideAllowed() || (bean.get(prop.getName()) == null));
                       */
// GemStone changes END
            }
        });

        Column[] columns = new Column[relevantProperties.size()];
        int      idx     = 0;

        for (Iterator propIt = relevantProperties.iterator(); propIt.hasNext(); idx++)
        {
            columns[idx] = ((SqlDynaProperty)propIt.next()).getColumn();
        }
        return columns;
    }
项目:gemfirexd-oss    文件:Table.java   
/**
 * Gets a list of non-unique indices on this table.
 * 
 * @return The unique indices
 */
public Index[] getNonUniqueIndices()
{
    Collection nonUniqueIndices = CollectionUtils.select(_indices, new Predicate() {
        public boolean evaluate(Object input) {
            return !((Index)input).isUnique();
        }
    });

    return (Index[])nonUniqueIndices.toArray(new Index[nonUniqueIndices.size()]);
}