当前位置: 首页>>代码示例>>Java>>正文


Java Collection.contains方法代码示例

本文整理汇总了Java中java.util.Collection.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.contains方法的具体用法?Java Collection.contains怎么用?Java Collection.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collection的用法示例。


在下文中一共展示了Collection.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNonConflicting

import java.util.Collection; //导入方法依赖的package包/类
/**
 * testNonConflicting
 */
public void testNonConflicting() throws Exception {
    // Make a single-partition txn for a procedure that has no conflicts with
    // our dtxn and add it to our queue. It should always be returned 
    // and marked as speculative by the scheduler
    Collection<Procedure> conflicts = ConflictSetUtil.getAllConflicts(dtxn.getProcedure());
    Procedure proc = null;
    for (Procedure p : catalogContext.getRegularProcedures()) {
        if (conflicts.contains(p) == false) {
            proc = p;
            break;
        }
    } // FOR
    assertNotNull(proc);
    
    LocalTransaction ts = new LocalTransaction(this.hstore_site);
    ts.testInit(this.idManager.getNextUniqueTransactionId(), BASE_PARTITION, null, catalogContext.getPartitionSetSingleton(BASE_PARTITION), proc);
    assertTrue(ts.isPredictSinglePartition());
    this.addToQueue(ts);
    
    LocalTransaction next = this.scheduler.next(this.dtxn, SpeculationType.IDLE);
    //System.err.println(this.dtxn.debug());
    assertNotNull(next);
    assertEquals(ts, next);
    assertFalse(this.work_queue.contains(next));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:TestSpecExecScheduler.java

示例2: load

import java.util.Collection; //导入方法依赖的package包/类
@Override
public void load(STATE_TYPE state)
{
	final Collection<String> choiceIds = getSavedChoiceIds(state);
	for( Entry<NameValue, DynamicChoicePanel<STATE_TYPE>> choice : choices.entrySet() )
	{
		final DynamicChoicePanel<STATE_TYPE> choicePanel = choice.getValue();
		if( choiceIds.contains(choicePanel.getId()) )
		{
			setSelectedChoiceComponent(choice.getKey());
			choicePanel.load(state);
		}
		else if( isLoadStateForNonSelectedChoices() )
		{
			choicePanel.load(state);
		}
	}
	// since checkboxes don't fire events when setSelected() is called:
	updateChoicePanels();
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:CheckboxChoiceList.java

示例3: lackAllRoles

import java.util.Collection; //导入方法依赖的package包/类
public static boolean lackAllRoles(String... roles) {
    if (roles == null) {
        logger.warn("roles is null");

        return true;
    }

    Collection<String> attributes = getRoles();

    for (String role : roles) {
        if (attributes.contains(role)) {
            logger.debug("has : {}", role);

            return false;
        }
    }

    return true;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:SpringSecurityUtils.java

示例4: MultiFormatUPCEANReader

import java.util.Collection; //导入方法依赖的package包/类
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) {
  @SuppressWarnings("unchecked")
  Collection<BarcodeFormat> possibleFormats = hints == null ? null :
      (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<UPCEANReader> readers = new ArrayList<>();
  if (possibleFormats != null) {
    if (possibleFormats.contains(BarcodeFormat.EAN_13)) {
      readers.add(new EAN13Reader());
    } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) {
      readers.add(new UPCAReader());
    }
    if (possibleFormats.contains(BarcodeFormat.EAN_8)) {
      readers.add(new EAN8Reader());
    }
    if (possibleFormats.contains(BarcodeFormat.UPC_E)) {
      readers.add(new UPCEReader());
    }
  }
  if (readers.isEmpty()) {
    readers.add(new EAN13Reader());
    // UPC-A is covered by EAN-13
    readers.add(new EAN8Reader());
    readers.add(new UPCEReader());
  }
  this.readers = readers.toArray(new UPCEANReader[readers.size()]);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:MultiFormatUPCEANReader.java

示例5: depopulateManager

import java.util.Collection; //导入方法依赖的package包/类
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem)contributionItem).getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:30,代码来源:OCCIActionBarContributor.java

示例6: testGetTicketsFromRegistryEqualToTicketsAdded

import java.util.Collection; //导入方法依赖的package包/类
@Test
public void testGetTicketsFromRegistryEqualToTicketsAdded() {
    final Collection<Ticket> tickets = new ArrayList<Ticket>();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", "test");

    for (int i = 0; i < TICKETS_IN_REGISTRY; i++) {
        final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl(
                "TEST" + i, TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy());
        final ServiceTicket st = ticketGrantingTicket.grantServiceTicket(
                "tests" + i, SimpleWebApplicationServiceImpl.createServiceFrom(request),
                new NeverExpiresExpirationPolicy(), false);
        tickets.add(ticketGrantingTicket);
        tickets.add(st);
        this.ticketRegistry.addTicket(ticketGrantingTicket);
        this.ticketRegistry.addTicket(st);
    }

    try {
        Collection<Ticket> ticketRegistryTickets = this.ticketRegistry.getTickets();
        assertEquals(
                "The size of the registry is not the same as the collection.",
                ticketRegistryTickets.size(), tickets.size());

        for (final Ticket ticket : tickets) {
            if (!ticketRegistryTickets.contains(ticket)) {
                fail("Ticket was added to registry but was not found in retrieval of collection of all tickets.");
            }
        }
    } catch (final Exception e) {
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:35,代码来源:JBossCacheTicketRegistryTests.java

示例7: containsAll

import java.util.Collection; //导入方法依赖的package包/类
public static <T> boolean containsAll(Collection<T> col, Iterable<T> data) {
    for (T item:data) {
        if(!col.contains(item))
            return false;
    }
    return true;
}
 
开发者ID:isel-leic-mpd,项目名称:mpd-2017-i41d,代码行数:8,代码来源:LazyQueries.java

示例8: addClientBehavior

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Utility method to assist sub-classes in the implementation of the
 * {@link javax.faces.component.behavior.ClientBehaviorHolder} interface.
 * <p>This method must only
 * be called by classes that implement the interface, doing otherwise will result in an exception.
 * </p>
 * @param eventName The event name
 * @param behavior The behavior to add
 * @see javax.faces.component.behavior.ClientBehaviorHolder#addClientBehavior(String, ClientBehavior)
 */
protected void addClientBehavior(
  String         eventName,
  ClientBehavior behavior)
{
  // This will throw a class cast exception when illegally called by a class that does not
  // implement ClientBehaviorHolder
  Collection<String> events = ((ClientBehaviorHolder)this).getEventNames();

  // This will throw a null pointer exception if the component author did not correctly implement
  // the ClientBehaviorHolder contract which requires a non-empty collection to be returned from
  // getEventNames
  if (!events.contains(eventName))
  {
    return;
  }

  FacesBean bean = getFacesBean();

  AttachedObjects<String, ClientBehavior> behaviors = (
          AttachedObjects<String, ClientBehavior>)bean.getProperty(_CLIENT_BEHAVIORS_KEY);

  if (behaviors == null)
  {
    behaviors = new AttachedObjects<String, ClientBehavior>();
    bean.setProperty(_CLIENT_BEHAVIORS_KEY, behaviors);
  }

  behaviors.addAttachedObject(eventName, behavior);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:40,代码来源:UIXComponentBase.java

示例9: initApplication

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Initializes balance.
 *
 * <p>Spring profiles can be configured with a program arguments --spring.profiles.active=your-active-profile
 *
 * <p>You can find more information on how profiles work with JHipster on <a href="http://www.jhipster.tech/profiles/">http://www.jhipster.tech/profiles/</a>.
 */
@PostConstruct
public void initApplication() {
    Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
    if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
        && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
        log.error("You have misconfigured your application! It should not run "
            + "with both the 'dev' and 'prod' profiles at the same time.");
    }
    if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
        && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
        log.error("You have misconfigured your application! It should not "
            + "run with both the 'dev' and 'cloud' profiles at the same time.");
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-balance,代码行数:22,代码来源:BalanceApp.java

示例10: removeAll

import java.util.Collection; //导入方法依赖的package包/类
@Override public boolean removeAll(Collection<?> c) {
  try {
    return super.removeAll(checkNotNull(c));
  } catch (UnsupportedOperationException e) {
    Set<K> toRemove = Sets.newHashSet();
    for (Entry<K, V> entry : map().entrySet()) {
      if (c.contains(entry.getValue())) {
        toRemove.add(entry.getKey());
      }
    }
    return map().keySet().removeAll(toRemove);
  }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:14,代码来源:Maps.java

示例11: retainAll

import java.util.Collection; //导入方法依赖的package包/类
@Override
public boolean retainAll(Collection<?> c) {
  checkNotNull(c);
  boolean changed = false;
  for (C columnKey : Lists.newArrayList(columnKeySet().iterator())) {
    if (!c.contains(Maps.immutableEntry(columnKey, column(columnKey)))) {
      removeColumn(columnKey);
      changed = true;
    }
  }
  return changed;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:StandardTable.java

示例12: isUserAdmin

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Response isUserAdmin(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        @SuppressWarnings("unchecked")
        Collection<GrantedAuthority> authorities = (Collection<GrantedAuthority>) auth.getAuthorities();
        if (authorities!= null &&  authorities.contains(new SimpleGrantedAuthority(ApplicationProperties.get(PROP_JWALA_ROLE_ADMIN)))) {
            return ResponseBuilder.ok(JSON_RESPONSE_TRUE);
        }
    }
    return ResponseBuilder.ok(JSON_RESPONSE_FALSE);
}
 
开发者ID:cerner,项目名称:jwala,代码行数:13,代码来源:UserServiceRestImpl.java

示例13: addWorkingCopy

import java.util.Collection; //导入方法依赖的package包/类
/** Clones itself into a working copy option. For most options just add "this", for 
 * more complex ones override
 * @return the reference to new itself
 */
public final OptionImpl addWorkingCopy(Collection<OptionImpl> allOptions) {
    if (allOptions.contains(this)) {
        // find element that is equal
        Iterator it = allOptions.iterator();
        for(;;) {
            OptionImpl elem = (OptionImpl) it.next();
            if (elem.equals(this)) {
                return (OptionImpl)elem;
            }
        }
    } else {
        return handleAdd(allOptions);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:OptionImpl.java

示例14: inAllowedValues

import java.util.Collection; //导入方法依赖的package包/类
public static <T> T inAllowedValues(T objectValue, String objectName, Collection<T> allowedObjectValues) {

		notNull(objectValue, "objectValue");
		notNullOrEmpty(objectName, "objectName");
		notNull(allowedObjectValues, "allowedObjectValues");

		if (!allowedObjectValues.contains(objectValue)) {
			throw new IncorrectValueException(objectName, objectValue, allowedObjectValues);
		}
		return objectValue;
	}
 
开发者ID:bilu,项目名称:yaess,代码行数:12,代码来源:Contract.java

示例15: verifyGetTicketsFromRegistryEqualToTicketsAdded

import java.util.Collection; //导入方法依赖的package包/类
@Test
public void verifyGetTicketsFromRegistryEqualToTicketsAdded() {
    final Collection<Ticket> tickets = new ArrayList<>();

    for (int i = 0; i < TICKETS_IN_REGISTRY; i++) {
        final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl("TEST" + i,
                TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
        final ServiceTicket st = ticketGrantingTicket.grantServiceTicket("tests" + i, TestUtils.getService(),
                new NeverExpiresExpirationPolicy(), false);
        tickets.add(ticketGrantingTicket);
        tickets.add(st);
        this.ticketRegistry.addTicket(ticketGrantingTicket);
        this.ticketRegistry.addTicket(st);
    }

    try {
        final Collection<Ticket> ticketRegistryTickets = this.ticketRegistry.getTickets();
        assertEquals("The size of the registry is not the same as the collection.", ticketRegistryTickets.size(),
                tickets.size());

        for (final Ticket ticket : tickets) {
            if (!ticketRegistryTickets.contains(ticket)) {
                fail("Ticket was added to registry but was not found in retrieval of collection of all tickets.");
            }
        }
    } catch (final Exception e) {
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:AbstractTicketRegistryTests.java


注:本文中的java.util.Collection.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。