本文整理汇总了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));
}
示例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();
}
示例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;
}
示例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()]);
}
示例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);
}
}
}
}
}
示例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.");
}
}
示例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;
}
示例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);
}
示例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.");
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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.");
}
}