List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:com.formkiq.core.webflow.FlowManager.java
/** * Start new WebFlow.//from www . j a v a2s. c om * @param <T> {@link FlowEventProcessor} * @param request {@link HttpServletRequest} * @param eventProcessor Class * @param states {@link List} * @return {@link WebFlow} */ public static <T extends FlowEventProcessor> WebFlow start(final HttpServletRequest request, final Class<T> eventProcessor, final List<FlowState> states) { if (states.isEmpty()) { throw new IllegalArgumentException("states is empty"); } List<FlowState> newstates = new ArrayList<>(states); if (!FlowStateType.START.equals(newstates.get(0).getType())) { newstates.add(0, new FlowState(FlowStateType.START)); } if (!FlowStateType.START.equals(newstates.get(0).getType())) { newstates.add(0, new FlowState(FlowStateType.START)); } if (!last(newstates).isEnd()) { newstates.add(new FlowState(FlowStateType.END)); } int webflowSessionID = getNextWebFlowSessionId(request); WebFlow flow = new WebFlow(webflowSessionID, eventProcessor, newstates); request.getSession().setAttribute(getExecutionSessionKey(flow.getSessionKey()).getLeft(), flow); return flow; }
From source file:me.zhanghai.mipsasm.Cli.java
public static boolean checkCommandLine(CommandLine commandLine) { @SuppressWarnings("unchecked") List<String> args = (List<String>) commandLine.getArgList(); if (!args.isEmpty()) { System.err.println("Unknown argument: " + args); printHelp();// w ww .ja va 2 s. c o m return false; } else { return true; } }
From source file:com.thinkbiganalytics.jobrepo.query.model.transform.JobStatusTransform.java
/** * Enusre that the list contains a date matching Now - the Period. if not add it to the collection *///from w w w .jav a 2s. co m public static void ensureDateFromPeriodExists(List<JobStatusCount> jobStatusCounts, Period period) { //add in the very first date relative to the period if it doesnt exist with a count of 0 if (jobStatusCounts != null && !jobStatusCounts.isEmpty()) { //get the first min date in the result set Date firstDateInResultSet = jobStatusCounts.stream().map(jobStatusCount -> jobStatusCount.getDate()) .min(Date::compareTo).get(); Date firstDate = DateUtils.truncate(DateTimeUtil.getNowUTCTime().minus(period).toDate(), Calendar.DATE); boolean containsFirstDate = jobStatusCounts.stream() .anyMatch(jobStatusCount -> jobStatusCount.getDate().equals(firstDate)); if (!containsFirstDate) { JobStatusCount first = jobStatusCounts.get(0); JobStatusCount min = new JobStatusCountResult(first); min.setDate(firstDate); min.setCount(new Long(0)); jobStatusCounts.add(min); } } }
From source file:jp.primecloud.auto.tool.management.pccapi.PccApiGenerateService.java
public static void genarate(CommandLine commandLine) throws AutoException { Long userNo = Long.parseLong(commandLine.getOptionValue("userno")); String generateType = commandLine.getOptionValue("generatetype"); try {/*from w w w .ja va 2s.c o m*/ String userSql = "SELECT * FROM USER WHERE USER_NO =" + userNo; List<User> users = SQLMain.selectExecuteWithResult(userSql, User.class); User user = users.get(0); if (generateType != null && generateType.equals("accessId")) { String apiAccessId = ""; while (true) { apiAccessId = generateAccessId(); String apiSql = "SELECT * FROM API_CERTIFICATE WHERE API_ACCESS_ID ='" + apiAccessId + "'"; List<ApiCertificate> apiCertificates = SQLMain.selectExecuteWithResult(apiSql, ApiCertificate.class); if (apiCertificates.isEmpty()) { break; } } log.info(user.getUsername() + " ? accessId ?????"); System.out.println(apiAccessId); } else if (generateType != null && generateType.equals("secretKey")) { String apiSecretKey = ""; while (true) { apiSecretKey = generateSecretKey(); String apiSql = "SELECT * FROM API_CERTIFICATE WHERE API_SECRET_KEY ='" + apiSecretKey + "'"; List<ApiCertificate> apiCertificates = SQLMain.selectExecuteWithResult(apiSql, ApiCertificate.class); if (apiCertificates.isEmpty()) { break; } } log.info(user.getUsername() + " ? secretKey ?????"); System.out.println(apiSecretKey); } else { log.error("generateType ?????"); System.out.println("GENERATE_ERROR"); } } catch (Exception e) { log.error("PCC-API????????userNo:" + userNo + " generateType:" + generateType, e); System.out.println("GENERATE_ERROR"); } }
From source file:com.u2apple.tool.util.AndroidDeviceUtils.java
public static List<AndroidDeviceRanking> parse(List<AndroidDevice> devices) { List<AndroidDeviceRanking> androidDevices = new ArrayList<>(); if (devices != null && !devices.isEmpty()) { // devices.stream().forEach((device) -> { // androidDevices.add(new AndroidDeviceRanking(device)); // }); devices.stream().map(device -> new AndroidDeviceRanking(device)).forEach(androidDevices::add); }/*from www . ja v a2 s. com*/ return androidDevices; }
From source file:se.uu.it.cs.recsys.ruleminer.impl.FPGrowthImpl.java
/** * * @param singlePrefixPath, ordered single prefix path from a FP Tree * @return pairs of (frequent pattern, its support); returns empty map if * input is null or empty/*from www . j a v a2 s . c o m*/ */ public static Map<Set<Integer>, Integer> getFrequentPatternFromSinglePrefixPath(List<Item> singlePrefixPath) { if (singlePrefixPath == null || singlePrefixPath.isEmpty()) { LOGGER.warn("Nonsence to give null or empty input. Do you agree?"); return Collections.EMPTY_MAP; } Set<Item> itemSetFromPath = new HashSet<>(singlePrefixPath); Set<Set<Item>> powerSet = Sets.powerSet(itemSetFromPath); Map<Set<Integer>, Integer> r = new HashMap<>(); Util.removeEmptySet(powerSet).forEach(itemSet -> { int localMinSupport = FPTreeUtil.getMinSupport(itemSet); r.put(itemSet.stream().map(item -> item.getId()).collect(Collectors.toSet()), localMinSupport); }); return r; }
From source file:io.lavagna.service.ProjectService.java
private static <T> T firstOrNull(List<T> t) { return t.isEmpty() ? null : t.get(0); }
From source file:com.lonepulse.robozombie.util.Is.java
/** * <p>Determines if the given type terminates an endpoint lookup along an inheritance hierarchy.</p> * /*w w w .j av a 2 s . c om*/ * <p>This evaluation is performed using a basic conditional check which will return {@code true} if * the given type is in the specified packages list. If a package list is not provided, the hierarchy * is deemed to have terminated if the given type is ina a package whose name starts with <b>"android."</b>, * <b>"java."</b>, <b>"javax."</b> or <b>"junit."</b>.</p> * * <p>Will be rendered obsolete if a future enhancement allows isolation of packages to scan for * endpoint injection.</p> * * @param type * the {@link Class} of the type to be checked for hierarchy termination * <br><br> * @param packagePrefixes * the packages prefixes to restrict the inheritance hierarchy to; else {@code null} * or {@code empty} to specify the <b>restriction packages</b> as "android.", "java.", * "javax." or "junit." * <br><br> * @return {@code true} if this type represents a termination in the hierarchy * <br><br> * @since 1.2.4 */ public static boolean hierarchyTerminal(Class<?> type, List<String> packagePrefixes) { String name = type.getName(); if (packagePrefixes != null && !packagePrefixes.isEmpty()) { for (String packagePrefix : packagePrefixes) { if (name.startsWith(packagePrefix)) { return false; } } return true; } return name.startsWith("android.") || name.startsWith("java.") || name.startsWith("javax.") || name.startsWith("junit."); }
From source file:me.fromgate.facechat.UpdateChecker.java
/** * Setup update message (could contains few lines) * Supported placeholders:/*from w ww. j av a 2s . co m*/ * %plugin% %newversion% %oldversion% %url% * * @param list - String list containing message * if list is empty will filled with default messages * * Example: * List<String> list = new ArrayList<String>(); * list.add("&6%plugin% &eis outdated! Recommended version is &6v%newversion%"); * list.add("&ePlease download new version from BukkitDev:"); * list.add("&b%url%"); * UpdateChecker.setUpdateMessage(list); * */ public static void setUpdateMessage(List<String> list) { if (list == null || list.isEmpty()) { updateMessages = new ArrayList<String>(); updateMessages.add("&6%plugin% &eis outdated! Recommended version is &6v%newversion%"); updateMessages.add("&ePlease download new version from BukkitDev:"); updateMessages.add("&b%url%"); } else updateMessages = list; }
From source file:ca.uhn.fhir.util.OperationOutcomeUtil.java
private static String getFirstIssueStringPart(FhirContext theCtx, IBaseOperationOutcome theOutcome, String name) {/* w w w. j ava 2 s . co m*/ if (theOutcome == null) { return null; } RuntimeResourceDefinition ooDef = theCtx.getResourceDefinition(theOutcome); BaseRuntimeChildDefinition issueChild = ooDef.getChildByName("issue"); List<IBase> issues = issueChild.getAccessor().getValues(theOutcome); if (issues.isEmpty()) { return null; } IBase issue = issues.get(0); BaseRuntimeElementCompositeDefinition<?> issueElement = (BaseRuntimeElementCompositeDefinition<?>) theCtx .getElementDefinition(issue.getClass()); BaseRuntimeChildDefinition detailsChild = issueElement.getChildByName(name); List<IBase> details = detailsChild.getAccessor().getValues(issue); if (details.isEmpty()) { return null; } return ((IPrimitiveType<?>) details.get(0)).getValueAsString(); }