List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:OSGiLocator.java
/** * Finds the preferred provider for the given service. The preferred provider * is the last one added to the set of providers. * //from ww w.j a va2s . c o m * @param serviceName * The fully qualified name of the service interface. * @return The last provider added for the service if any exists. Otherwise, * it returns <tt>null</tt>. * @throws IllegalArgumentException * if serviceName is <tt>null</tt> */ public static synchronized Class<?> locate(final String serviceName) { if (serviceName == null) { throw new IllegalArgumentException("serviceName cannot be null"); } if (factories != null) { List<Callable<Class<?>>> l = factories.get(serviceName); if (l != null && !l.isEmpty()) { Callable<Class<?>> c = l.get(l.size() - 1); try { return c.call(); } catch (Exception e) { } } } return null; }
From source file:be.fedict.eid.applet.service.signer.odf.ODFSignatureVerifier.java
/** * Checks whether the ODF document available via the given URL has been * signed.//from w ww.j a va 2 s. c o m * * @param odfUrl * @return * @throws IOException * @throws ParserConfigurationException * @throws SAXException * @throws org.apache.xml.security.signature.XMLSignatureException * @throws XMLSecurityException * @throws MarshalException * @throws XMLSignatureException */ public static boolean hasOdfSignature(URL odfUrl) throws IOException, ParserConfigurationException, SAXException, org.apache.xml.security.signature.XMLSignatureException, XMLSecurityException, MarshalException, XMLSignatureException { List<X509Certificate> signers = getSigners(odfUrl); return false == signers.isEmpty(); }
From source file:ch.ksfx.util.calc.AssetPriceSparser.java
public static List<Observation> sparseAssetPriceWithoutAveragingObservation(List<Observation> assetPrices, Integer sparsingSeconds) { Collections.sort(assetPrices, new ObservationDateComparator()); Integer currentIndex = 0;// ww w . j ava 2s . com List<Observation> sparsedPrices = new ArrayList<Observation>(); for (Observation ap : assetPrices) { if (sparsedPrices.isEmpty()) { sparsedPrices.add(ap); } if (DateUtils.addSeconds(sparsedPrices.get(currentIndex).getObservationTime(), sparsingSeconds) .before(ap.getObservationTime())) { sparsedPrices.add(ap); currentIndex++; } } return sparsedPrices; }
From source file:jp.primecloud.auto.tool.management.main.ConfigMain.java
public static void showPlatforms() { try {/* ww w. j av a 2 s . c o m*/ String sql = "SELECT * FROM PLATFORM"; List<Platform> platforms = SQLMain.selectExecuteWithResult(sql, Platform.class); if (platforms.isEmpty()) { System.out.println("??????"); return; } StringBuilder titles = new StringBuilder(); titles.append(StringUtils.rightPad("PlatformName", PAD_SIZE, " ")); titles.append(StringUtils.rightPad("Status", PAD_SIZE, " ")); System.out.println(titles.toString()); for (Platform platform : platforms) { List<String> columns = new ArrayList<String>(); columns.add(platform.getPlatformName()); // ?? if (BooleanUtils.isTrue(platform.getSelectable())) { columns.add("enable"); } else { columns.add("disable"); } for (String column : columns) { System.out.print(StringUtils.rightPad(column, PAD_SIZE, " ")); } System.out.println(); } } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage(), e); } }
From source file:org.jboss.aerogear.unifiedpush.utils.perf.BatchUtils.java
public static void registerApplicationsViaBatchEndpoint(MassPushApplication massive, Session session) { List<PushApplication> pushApplications = new ArrayList<PushApplication>(massive.getApplications()); while (!pushApplications.isEmpty()) { int toIndex = APPLICATION_PAGING; if (pushApplications.size() < APPLICATION_PAGING) { toIndex = pushApplications.size(); }//www .j a v a2s. c o m List<PushApplication> sublist = pushApplications.subList(0, toIndex); MassPushApplication mass = new MassPushApplication(); mass.setApplications(sublist); Response response = session.givenAuthorized().contentType(ContentTypes.json()) .header(Headers.acceptJson()).body(mass).post("/rest/mass/applications/generated"); UnexpectedResponseException.verifyResponse(response, HttpStatus.SC_OK); pushApplications.removeAll(sublist); } }
From source file:org.keycloak.connections.httpclient.ProxyMappings.java
/** * Creates a new {@link ProxyMappings} from the provided {@code List} of proxy mapping strings. * <p>//from w w w . j a v a 2 s . com * * @param proxyMappings */ public static ProxyMappings valueOf(List<String> proxyMappings) { if (proxyMappings == null || proxyMappings.isEmpty()) { return EMPTY_MAPPING; } List<ProxyMapping> entries = proxyMappings.stream() // .map(ProxyMapping::valueOf) // .collect(Collectors.toList()); return new ProxyMappings(entries); }
From source file:com.openquartz.glassmemo.Utils.java
public static void commitNewMemoList(final Context context, final String key, final List<String> memoList) { SharedPreferences.Editor sharedPrefEditor = PreferenceManager.getDefaultSharedPreferences(context).edit(); if (!memoList.isEmpty()) { sharedPrefEditor.putString(key, new JSONArray(memoList).toString()); } else {//from w w w . java2s . c o m sharedPrefEditor.putString(key, null); } sharedPrefEditor.commit(); }
From source file:gestion.GestorUsuario.java
public static JSONObject getLogin(String login, String pass) throws JSONException { Configuration configuration = new Configuration().configure(); StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder() .applySettings(configuration.getProperties()); SessionFactory factory = configuration.buildSessionFactory(builder.build()); Session sesion = factory.openSession(); sesion.beginTransaction();// w w w.jav a 2s .co m String hql = "from Usuario where login = :login and pass = :pass"; Query q = sesion.createQuery(hql); q.setString("login", login); q.setString("pass", pass); List<Usuario> usuarios = q.list(); sesion.getTransaction().commit(); sesion.flush(); sesion.close(); JSONObject obj = new JSONObject(); if (usuarios.isEmpty()) { obj.put("r", false); } else { obj.put("r", true); } return obj; }
From source file:Main.java
/** * Combines two lists into map, using first list as keys and second as values * * @param keys List used as keys/*from w ww . j a v a 2 s. com*/ * @param values List used as values * @param <K> Type of values in keys list * @param <V> Type of values in values list * @return {@link LinkedHashMap} */ public static <K, V> Map<K, V> combineLists(List<? extends K> keys, List<? extends V> values) { if (keys.size() != values.size()) { throw new IllegalArgumentException("Cannot combine lists with dissimilar sizes"); } if (keys.isEmpty() && values.isEmpty()) { return Collections.emptyMap(); } int size = values.size(); Map<K, V> map = new LinkedHashMap<>(size); for (int i = 0; i < size; i++) { map.put(keys.get(i), values.get(i)); } return map; }
From source file:gate.termraider.util.Utilities.java
public static double meanDoubleList(List<Double> list) { if (list.isEmpty()) { return 0.0; }/* ww w.j a va2 s .c o m*/ // implied else double total = 0.0; for (Double item : list) { total += item; } return total / ((double) list.size()); }