List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions.java
private Actions(List<Set<RequestedAction>> oldList, Collection<RequestedAction> newActions) { List<Set<RequestedAction>> newList = new ArrayList<Set<RequestedAction>>(); newList.addAll(oldList);//from w w w .j ava2 s .c o m Set<RequestedAction> newActionSet = new HashSet<RequestedAction>(newActions); if (!newActionSet.isEmpty()) { newList.add(Collections.unmodifiableSet(newActionSet)); } this.clauseList = Collections.unmodifiableList(newList); }
From source file:net.sfr.tv.mom.mgt.handlers.InvocationHandler.java
@Override public Object execute(MBeanServerConnection connection, Object[] args) { if (this.expression.indexOf("{") != -1) { this.expression = renderExpression(new Object[] { "\"".concat(args[0].toString()).concat("\"") }); args = Arrays.copyOfRange(args, 1, args.length); }//from w w w.j a v a 2 s. co m try { final Set<ObjectName> oNames = connection.queryNames(new ObjectName(expression), null); if (oNames == null || oNames.isEmpty()) { LOGGER.severe("No object names returns for expression '" + expression + "'"); return null; } else { final Object result = connection.invoke(oNames.iterator().next(), operation.getName(), args, operation.getSignature()); if (result == null) { LOGGER.warning("Result of operation '" + operation.getName() + "'is null"); return result; } return formatter.format(result); } //result = connection.invoke(new ObjectName(expression), operation.getName(), new Object[operation.getSignature().length], operation.getSignature()); } catch (MBeanException | IllegalArgumentException | InstanceNotFoundException | MalformedObjectNameException | ReflectionException | IOException ex) { LOGGER.log(Level.SEVERE, null, ex); return null; } }
From source file:com.cloudera.parcel.validation.components.AlternativesDescriptorValidatorImplTest.java
@Test public void testMinimal() { Set<ConstraintViolation<AlternativesDescriptor>> violations = validator .getViolations(ParcelTestUtils.getParserAlternativesJson("empty.json")); assertTrue(violations.isEmpty()); }
From source file:com.cloudera.parcel.validation.components.ManifestDescriptorValidatorImplTest.java
@Test public void testValid() { Set<ConstraintViolation<ManifestDescriptor>> violations = validator .getViolations(ParcelTestUtils.getParserManifestJson("good_manifest.json")); assertTrue(violations.isEmpty()); }
From source file:io.lavagna.service.CardEventRepositoryTest.java
@Test public void findUsersIdFor() { CardData cd = cardDataService.createComment(card1.getId(), "test", new Date(), user); Set<Integer> res1 = eventRepository.findUsersIdFor(cd.getId(), EventType.COMMENT_CREATE); Assert.assertTrue(res1.size() == 1); Assert.assertTrue(res1.contains(user.getId())); Set<Integer> res2 = eventRepository.findUsersIdFor(cd.getId(), EventType.COMMENT_UPDATE); Assert.assertTrue(res2.isEmpty()); cardDataService.updateComment(cd.getId(), "test 2", new Date(), user2); cardDataService.updateComment(cd.getId(), "test", new Date(), user); Set<Integer> res3 = eventRepository.findUsersIdFor(cd.getId(), EventType.COMMENT_UPDATE); Assert.assertTrue(res3.size() == 2); Assert.assertTrue(res3.contains(user.getId())); Assert.assertTrue(res3.contains(user2.getId())); }
From source file:nz.co.senanque.perspectiveslibrary.BundleListenerImpl.java
private BundleVersion getLatestVersion(String name) { Set<BundleVersion> bundles = m_map.get(name); if (bundles == null || bundles.isEmpty()) { // No bundles of this name yet return null return null; } else {// ww w . java 2s . c o m // we do have bundles of this name so get the latest version return bundles.iterator().next(); // gets the first one in the set } }
From source file:biz.netcentric.bitbucket.plugins.jenkins.JenkinsBuildTrigger.java
/** * Notifies Jenkins of a new commit assuming Jenkins is configured to connect to Stash via SSH. *///from w w w .j a v a2s. c om public void postReceive(final RepositoryHookContext context, final Collection<RefChange> refChanges) { String url = context.getSettings().getString(PROPERTY_URL); if (StringUtils.isBlank(url)) { url = (String) transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction() { return pluginSettingsFactory.createGlobalSettings().get(ConfigResource.PLUGIN_KEY_URL); } }); } try { final RepositoryCloneLinksRequest linksRequest = new RepositoryCloneLinksRequest.Builder() .protocol("ssh").repository(context.getRepository()).build(); final Set<NamedLink> links = repositoryService.getCloneLinks(linksRequest); if (links.isEmpty()) { LOG.error("Unable to calculate clone link for repository [{}]", context.getRepository()); } else { url = String.format("%s/git/notifyCommit?url=%s", url, URLEncoder.encode(links.iterator().next().getHref(), "UTF-8")); } } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage(), e); } LOG.debug("Notifying Jenkins via URL: [{}]", url); if (url != null) { try { new URL(url).openConnection().getInputStream().close(); } catch (Exception e) { LOG.error("Unable to connect to Jenkins at [" + url + "]", e); } } }
From source file:de.hybris.platform.b2bacceleratorservices.strategies.impl.DefaultB2BDeliveryAddressesLookupStrategy.java
@Override public List<AddressModel> getDeliveryAddressesForOrder(final AbstractOrderModel abstractOrder, final boolean visibleAddressesOnly) { if (CheckoutPaymentType.ACCOUNT.equals(abstractOrder.getPaymentType())) { // Lookup the final B2BCostCenterModel costCenter = getCostCenterForOrder(abstractOrder); if (costCenter != null) { final Set<AddressModel> addresses = collectAddressesForCostCenter(costCenter); if (addresses != null && !addresses.isEmpty()) { return sortAddresses(addresses); }//from w w w . j a va 2 s .c o m } // Can't find any pay on account addresses yet - maybe the cost centre is not set yet? return Collections.emptyList(); } else { // Use fallback return getFallbackDeliveryAddressesLookupStrategy().getDeliveryAddressesForOrder(abstractOrder, visibleAddressesOnly); } }
From source file:org.usrz.libs.webtools.validation.ValidationInterceptor.java
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { final Object object = context.proceed(); if (object == null) return null; log.debug("Validating class %s", object.getClass().getName()); final Set<ConstraintViolation<Object>> violations = validator.validate(object); if ((violations == null) || (violations.isEmpty())) return object; final List<Error> errors = new ArrayList<>(); violations.forEach((violation) -> errors.add(new Error(violation))); throw new WebApplicationExceptionBuilder(BAD_REQUEST).message("Violation constraint in API") .with(withName, errors).build(); }
From source file:net.maritimecloud.identityregistry.validators.OrganizationValidatorTests.java
@Test public void validateValidOrg() { Organization validOrg = new Organization(); validOrg.setName("Test Org"); validOrg.setMrn("urn:mrn:mcl:org:test"); validOrg.setAddress("Test address"); validOrg.setCountry("Test Country"); validOrg.setEmail("email@test.org"); validOrg.setUrl("http://test.org"); Set<ConstraintViolation<Organization>> violations = validator.validate(validOrg); assertTrue(violations.isEmpty()); }