List of usage examples for java.util List equals
boolean equals(Object o);
From source file:org.apache.storm.verify.VerifyUtils.java
public static void verifyHdfs(String hdfsUrl, String dir, List<String> expectedLines) throws Exception { List<String> lines = new ArrayList<String>(); FileSystem fileSystem = FileSystem.get(new URI(hdfsUrl), new Configuration()); Path path = new Path(dir); assert fileSystem.exists(path); assert fileSystem.isDirectory(path); FileStatus[] fileStatuses = fileSystem.listStatus(path); assert fileStatuses != null; for (FileStatus fileStatus : fileStatuses) { Path filePath = fileStatus.getPath(); InputStreamReader is = new InputStreamReader(fileSystem.open(filePath)); lines.addAll(IOUtils.readLines(is)); }/*from ww w . j av a 2s.c o m*/ Collections.sort(lines); Collections.sort(expectedLines); assert lines.equals(expectedLines) : "expectedLines = " + expectedLines + " actualines = " + lines; }
From source file:org.apache.hadoop.hbase.security.visibility.DefaultVisibilityLabelServiceImpl.java
private static boolean compareTagsOrdinals(List<List<Integer>> putVisTags, List<List<Integer>> deleteVisTags) { boolean matchFound = false; if (deleteVisTags.size() == putVisTags.size()) { for (List<Integer> deleteTagOrdinals : deleteVisTags) { matchFound = false;// www.j a v a 2 s . c o m for (List<Integer> tagOrdinals : putVisTags) { if (deleteTagOrdinals.equals(tagOrdinals)) { matchFound = true; break; } } if (!matchFound) break; } } return matchFound; }
From source file:org.apache.gobblin.data.management.conversion.hive.converter.AbstractAvroToOrcConverter.java
/** * Parse the {@link #REPLACED_PARTITIONS_HIVE_METASTORE_KEY} from partition parameters to returns DDLs for all the partitions to be * dropped./* w ww . java 2 s .c o m*/ * * @return A {@link List} of partitions to be dropped. Each element of the list is a {@link Map} which maps a partition's * key and value. * */ public static List<Map<String, String>> getDropPartitionsDDLInfo(Partition hivePartition) { List<Map<String, String>> replacedPartitionsDDLInfo = Lists.newArrayList(); List<FieldSchema> partitionKeys = hivePartition.getTable().getPartitionKeys(); if (StringUtils.isNotBlank(hivePartition.getParameters().get(REPLACED_PARTITIONS_HIVE_METASTORE_KEY))) { // Partitions are separated by "|" for (String partitionsInfoString : Splitter.on("|").omitEmptyStrings() .split(hivePartition.getParameters().get(REPLACED_PARTITIONS_HIVE_METASTORE_KEY))) { // Values for a partition are separated by "," List<String> partitionValues = Splitter.on(",").omitEmptyStrings().trimResults() .splitToList(partitionsInfoString); // Do not drop the partition being processed. Sometimes a partition may have replaced another partition of the same values. if (!partitionValues.equals(hivePartition.getValues())) { ImmutableMap.Builder<String, String> partitionDDLInfoMap = ImmutableMap.builder(); for (int i = 0; i < partitionKeys.size(); i++) { partitionDDLInfoMap.put(partitionKeys.get(i).getName(), partitionValues.get(i)); } replacedPartitionsDDLInfo.add(partitionDDLInfoMap.build()); } } } return replacedPartitionsDDLInfo; }
From source file:org.apache.fop.complexscripts.bidi.BidiResolver.java
private static List reorderRuns(List runs, int level) { assert level >= 0; List runsNew = new Vector(); for (int i = 0, n = runs.size(); i < n; i++) { InlineRun iri = (InlineRun) runs.get(i); if (iri.getMinLevel() < level) { runsNew.add(iri);// w w w. j a va 2 s . c om } else { int s = i; int e = s; while (e < n) { InlineRun ire = (InlineRun) runs.get(e); if (ire.getMinLevel() < level) { break; } else { e++; } } if (s < e) { runsNew.addAll(reverseRuns(runs, s, e)); } i = e - 1; } } if (!runsNew.equals(runs)) { runs = runsNew; } return runs; }
From source file:YexTool.java
private static boolean isValidAssets(OpenRtb.BidResponse.SeatBid.Bid bid, Map<String, OpenRtb.BidRequest.Imp> impId2Imps) { OpenRtb.BidRequest.Imp requestImp = impId2Imps.get(bid.getImpid()); if (requestImp == null) { logger.warn("ImpId invalid! " + bid.getImpid() + " are not in required ImpIds: " + impId2Imps.keySet()); return false; }/*from w w w. j a v a 2 s . c o m*/ List<OpenRtb.NativeRequest.Asset> requestAssets = requestImp.getNative().getRequestNative().getAssetsList(); if (requestAssets.isEmpty()) { logger.warn("Empty asset for Imp: " + requestImp); return false; } List<Integer> requestAssetIds = new ArrayList<Integer>(requestAssets.size()); for (OpenRtb.NativeRequest.Asset asset : requestAssets) { requestAssetIds.add(asset.getId()); } List<Integer> bidAssetIds = new ArrayList<Integer>(); Map<Integer, OpenRtb.NativeResponse.Asset> bidAssetId2Asset = new HashMap<Integer, OpenRtb.NativeResponse.Asset>(); for (OpenRtb.NativeResponse.Asset asset : bid.getAdmNative().getAssetsList()) { bidAssetIds.add(asset.getId()); bidAssetId2Asset.put(asset.getId(), asset); } Collections.sort(requestAssetIds); Collections.sort(bidAssetIds); boolean valid = requestAssetIds.equals(bidAssetIds); if (!valid) { logger.warn( "Bid's assetIds:" + bidAssetIds + " are not matched to required assets: " + requestAssetIds); return false; } for (OpenRtb.NativeRequest.Asset requestAsset : requestAssets) { OpenRtb.NativeResponse.Asset bidAsset = bidAssetId2Asset.get(requestAsset.getId()); if (requestAsset.hasTitle()) { valid = bidAsset.hasTitle() && bidAsset.getTitle().getText().length() <= requestAsset.getTitle().getLen(); } else if (requestAsset.hasImg()) { valid = bidAsset.hasImg() && bidAsset.getImg().getW() == requestAsset.getImg().getW() && bidAsset.getImg().getH() == requestAsset.getImg().getH(); } else if (requestAsset.hasData()) { valid = bidAsset.hasData(); } else { //TODO: Video valid = false; } if (!valid) { logger.warn("Bid's asset: " + bidAsset + " are not matched to required asset: " + requestAsset); return false; } } return true; }
From source file:gobblin.data.management.conversion.hive.converter.AbstractAvroToOrcConverter.java
/** * Parse the {@link #REPLACED_PARTITIONS_HIVE_METASTORE_KEY} from partition parameters to returns DDLs for all the partitions to be * dropped./*w w w . j a v a 2 s . c om*/ * * @return A {@link List} of partitions to be dropped. Each element of the list is a {@link Map} which maps a partition's * key and value. * */ public static List<Map<String, String>> getDropPartitionsDDLInfo(Partition hivePartition) { List<Map<String, String>> replacedPartitionsDDLInfo = Lists.newArrayList(); List<FieldSchema> partitionKeys = hivePartition.getTable().getPartitionKeys(); if (StringUtils.isNotBlank(hivePartition.getParameters().get(REPLACED_PARTITIONS_HIVE_METASTORE_KEY))) { // Partitions are separated by "|" for (String partitionsInfoString : Splitter.on("|").omitEmptyStrings() .split(hivePartition.getParameters().get(REPLACED_PARTITIONS_HIVE_METASTORE_KEY))) { // Values for a partition are separated by "," List<String> partitionValues = Splitter.on(",").omitEmptyStrings().trimResults() .splitToList(partitionsInfoString); // Do not drop partition the being processed. Sometimes a partition may have replaced another partition of the same values. if (!partitionValues.equals(hivePartition.getValues())) { ImmutableMap.Builder<String, String> partitionDDLInfoMap = ImmutableMap.builder(); for (int i = 0; i < partitionKeys.size(); i++) { partitionDDLInfoMap.put(partitionKeys.get(i).getName(), partitionValues.get(i)); } replacedPartitionsDDLInfo.add(partitionDDLInfoMap.build()); } } } return replacedPartitionsDDLInfo; }
From source file:org.caleydo.view.bicluster.elem.ClusterElement.java
protected static List<List<Integer>> getListOfContinousIDs(List<Integer> overlap, List<Integer> indices) { List<List<Integer>> sequences = new ArrayList<List<Integer>>(); if (overlap.size() == 0) return sequences; List<Integer> accu = new ArrayList<Integer>(); for (Integer i : indices) { if (overlap.contains(i)) { accu.add(i);/*from www . j a v a 2 s . com*/ } else if (accu.size() > 0) { // don't add empty lists sequences.add(accu); accu = new ArrayList<>(); } } if (accu.size() > 0) sequences.add(accu); List<List<Integer>> r2 = getListOfContinousIDs2(overlap, indices); assert r2.equals(sequences); return sequences; }
From source file:org.wso2.carbon.apimgt.core.util.APIUtils.java
/** * Checks String lists for equality independent of the order of elements in the lists. * * Note that order of the elements in the lists will be changed as a result of sorting, * but this is not a concern usually since the order does not matter. * @param list1 String list// ww w . j a v a 2s . c o m * @param list2 String list * @return true if elements in lists are equal irrespective of order */ public static boolean isListsEqualIgnoreOrder(List<String> list1, List<String> list2) { if (list1 == null && list2 == null) { return true; } if (list1 == null || list2 == null || list1.size() != list2.size()) { return false; } // Sort lists so that the order of elements don't affect the equal check. // Note that order of the elements in the lists will be changed as a result but this is not a concern since // the order does not matter Collections.sort(list1); Collections.sort(list2); return list1.equals(list2); }
From source file:i5.las2peer.services.gamificationQuestService.GamificationQuestService.java
/** * Convert list of pair string and integer to JSON array * @return JSON array list of pair string and integer * @throws IOException IO exception/*from w w w . ja va2s. c om*/ */ private static JSONArray listPairtoJSONArray(List<Pair<String, Integer>> listpair) throws IOException { JSONArray arr = new JSONArray(); if (listpair.isEmpty() || listpair.equals(null)) { throw new IOException("List pair is empty"); } for (Pair<String, Integer> pair : listpair) { JSONObject obj = new JSONObject(); obj.put("actionId", pair.getLeft()); obj.put("times", pair.getRight()); arr.add(obj); } return arr; }
From source file:org.springframework.test.context.TestContextManagerTests.java
/** * Asserts the <em>execution order</em> of 'before' and 'after' test method * calls on {@link TestExecutionListener listeners} registered for the * configured {@link TestContextManager}. * * @see #beforeTestMethodCalls/*w w w .ja va2s . c om*/ * @see #afterTestMethodCalls */ private static void assertExecutionOrder(List<String> expectedBeforeTestMethodCalls, List<String> expectedAfterTestMethodCalls, final String usageContext) { if (expectedBeforeTestMethodCalls == null) { expectedBeforeTestMethodCalls = new ArrayList<String>(); } if (expectedAfterTestMethodCalls == null) { expectedAfterTestMethodCalls = new ArrayList<String>(); } if (logger.isDebugEnabled()) { for (String listenerName : beforeTestMethodCalls) { logger.debug("'before' listener [" + listenerName + "] (" + usageContext + ")."); } for (String listenerName : afterTestMethodCalls) { logger.debug("'after' listener [" + listenerName + "] (" + usageContext + ")."); } } assertTrue("Verifying execution order of 'before' listeners' (" + usageContext + ").", expectedBeforeTestMethodCalls.equals(beforeTestMethodCalls)); assertTrue("Verifying execution order of 'after' listeners' (" + usageContext + ").", expectedAfterTestMethodCalls.equals(afterTestMethodCalls)); }