List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:com.strategicgains.docussandra.ParseUtils.java
/** * Converts a string to a date. Uses DateAdaptorJ, if that fails, falls back * to Natty.//from w ww .j ava 2s.c o m * * @param in String to convert to a date. * @return A date based on the string. * @throws IndexParseFieldException If the field cannot be parsed as a date. */ public static Date parseStringAsDate(String in) throws IndexParseFieldException //TODO: come back to this and add more tests, i am not yet entirely happy with it { DateAdapter adapter = new DateAdapter(); try { return adapter.parse(in); } catch (ParseException e)//fall back to netty if that fails { Parser parser = new Parser(TimeZone.getTimeZone("GMT"));//assume all dates are GMT List<DateGroup> dg = parser.parse(in); if (dg.isEmpty()) { throw new IndexParseFieldException(in); } List<Date> dates = dg.get(0).getDates(); if (dates.isEmpty()) { throw new IndexParseFieldException(in); } return dates.get(0);//dang; that actually works } }
From source file:io.github.seleniumquery.functions.jquery.forms.ValFunction.java
public static String val(List<WebElement> elements) { if (elements.isEmpty()) { return null; }// w ww . j a v a 2 s .c om return val(elements.get(0)); }
From source file:org.sakaiproject.genericdao.springutil.ResourceFinder.java
private static List<Resource> makeResources(List<String> paths) { List<Resource> rs = new ArrayList<Resource>(); if (paths != null && !paths.isEmpty()) { ClassLoader cl = ResourceFinder.class.getClassLoader(); for (String path : paths) { Resource r = new ClassPathResource(path, cl); if (r.exists()) { rs.add(r);/*w ww .j av a 2 s.com*/ } } } return rs; }
From source file:com.addthis.bundle.util.AutoField.java
public static AutoField newAutoField(List<String> names, boolean parseIndex) { checkNotNull(names);/*from w w w .j av a2 s .co m*/ checkArgument(!names.isEmpty(), "list of field names must not be empty (usually >=2)"); String name = names.get(0); AutoField baseAutoField; if (parseIndex) { baseAutoField = new IndexField(name); } else { baseAutoField = new CachingField(name); } if (names.size() == 1) { return baseAutoField; } else { String[] subNames = names.subList(1, names.size()).toArray(new String[names.size() - 1]); return new FullAutoField(baseAutoField, subNames); } }
From source file:com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStatsTransform.java
/** * Converts the domain model objects to the rest model equivalent * * @param domains A list of domain objects * @return a list of converted objects, or null if the provided list was empty *//*w w w . j a va2s.c o m*/ public static List<NifiFeedProcessorStats> toModel( List<? extends com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats> domains) { if (domains != null && !domains.isEmpty()) { return domains.stream().map(domain -> toModel(domain)).collect(Collectors.toList()); } return null; }
From source file:edu.uci.ics.asterix.optimizer.base.AnalysisUtil.java
public final static ILogicalOperator firstChildOfType(AbstractLogicalOperator op, LogicalOperatorTag opType) { List<Mutable<ILogicalOperator>> ins = op.getInputs(); if (ins == null || ins.isEmpty()) { return null; }/*from ww w.ja va 2s .c o m*/ Mutable<ILogicalOperator> opRef2 = ins.get(0); AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue(); if (op2.getOperatorTag() == opType) { return op2; } else { return null; } }
From source file:com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStatsTransform.java
/** * Converts the domain model objects to the rest model equivalent * * @param domains A list of domain objects * @return a list of converted objects, or null if the provided list was empty *///from ww w . java 2 s. c om public static List<NifiFeedProcessorStatsErrors> toErrorsModel( List<? extends com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorErrors> domains) { if (domains != null && !domains.isEmpty()) { return domains.stream().map(domain -> toErrorsModel(domain)).collect(Collectors.toList()); } return null; }
From source file:com.wmw.bank.BankValidator.java
public static <T extends Account> T validate(T account) { checkNotNull(account, "Account can't be null."); checkState(account.getAccountNumber() > 0, "Account number must be grater than 0."); checkState(account.getRoutingNumber() > 0, "Routing number must be grater than 0."); List<? extends Owner> owners = account.getOwners(); checkNotNull(owners, "Owners can't be null."); checkState(!owners.isEmpty() && !owners.contains(null), "At least 1 owner required and every owner can't be null."); return account; }
From source file:com.aurel.track.plugin.JavaScriptPathExtenderAction.java
public static String getDirs() { List<File> dirs = PluginUtils.getJavaScriptExtensionDirs(); if (dirs == null || dirs.isEmpty()) { return ""; }/*from w w w.ja va 2s . c o m*/ StringBuffer pathMappings = new StringBuffer(); for (File dir : dirs) { String nameSpace = dir.getName(); String path = dir.getAbsolutePath(); //for ex. if a plugin name is 'reportPlugin' then: Ext.Loader.setPath('reportPlugin', 'loadJavaScript!load.action?file=reportPlugin/js'); //that means all js files defined in plugin should be defined as Ext.define('reportPlugin.<ReportConfigJSName>',{...}) pathMappings.append("Ext.Loader.setPath('" + nameSpace + "', 'loadJavaScript.action?pluginDir=" + nameSpace + "&file=');\n"); } return pathMappings.toString(); }
From source file:gdv.xport.Main.java
/** * Prints the violations.//from w ww . j av a 2s .c o m * * @param violations * the violations */ private static void printViolations(final List<ConstraintViolation> violations) { if (violations.isEmpty()) { System.out.println("keine Datensatz-Verletzung gefunden"); } else { for (ConstraintViolation violation : violations) { System.err.println(violation.getValidatedObject() + ": " + violation.getMessage()); } } }