List of usage examples for java.util List equals
boolean equals(Object o);
From source file:MainClass.java
public static void main(String[] a) { List list = Arrays.asList(new String[] { "A", "B", "C", "D" }); List list2 = Arrays.asList(new String[] { "A", "B", "C" }); System.out.println(list.equals(list2)); }
From source file:org.attoparser.html.bulk.HtmlBulkTester.java
public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Syntax: java " + HtmlBulkTester.class.getName() + " [test_folder]"); System.exit(1);/* w w w . java2s. co m*/ } final String testFolderName = args[0]; final File testFolder = new File(testFolderName); if (!testFolder.exists() || !testFolder.isDirectory()) { System.err.println("Folder " + testFolderName + " does not exist or is not a folder"); System.exit(1); } final MarkupParser parser = new MarkupParser(ParseConfiguration.htmlConfiguration()); System.out.println("Using temporary folder for output: " + System.getProperty("java.io.tmpdir")); final File[] filesInTestFolder = testFolder.listFiles(); for (final File fileInTestFolder : filesInTestFolder) { if (!fileInTestFolder.getName().endsWith(".html")) { continue; } final String fileInTestFolderName = fileInTestFolder.getName(); final FileInputStream fileInTestFolderStream = new FileInputStream(fileInTestFolder); final InputStreamReader fileInTestFolderReader = new InputStreamReader(fileInTestFolderStream, "UTF-8"); final File testOutput = File.createTempFile("attoparser-testing-" + fileInTestFolderName + "-", ".html"); testOutput.deleteOnExit(); final FileOutputStream testOutputStream = new FileOutputStream(testOutput); final OutputStreamWriter testOutputWriter = new OutputStreamWriter(testOutputStream, "UTF-8"); final OutputMarkupHandler handler = new OutputMarkupHandler(testOutputWriter); System.out.print(fileInTestFolderName); System.out.print("[PARSING]"); parser.parse(fileInTestFolderReader, handler); // Input stream will be closed by parser testOutputWriter.close(); testOutputStream.close(); System.out.print("[PARSED]"); final FileInputStream testOutputCheckStream = new FileInputStream(testOutput); final List<String> outputLines = IOUtils.readLines(testOutputCheckStream, "UTF-8"); final FileInputStream testInputCheckStream = new FileInputStream(fileInTestFolder); final List<String> inputLines = IOUtils.readLines(testInputCheckStream, "UTF-8"); System.out.print("[CHECKING]"); if (outputLines.equals(inputLines)) { System.out.print("[OK]"); } else { System.out.print("[KO]"); } System.out.println(); } }
From source file:org.thymeleaf.aurora.engine.HtmlBulkTester.java
public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Syntax: java " + HtmlBulkTester.class.getName() + " [test_folder]"); System.exit(1);//from ww w. j a v a 2 s .co m } final String testFolderName = args[0]; final File testFolder = new File(testFolderName); if (!testFolder.exists() || !testFolder.isDirectory()) { System.err.println("Folder " + testFolderName + " does not exist or is not a folder"); System.exit(1); } System.out.println("Using temporary folder for output: " + System.getProperty("java.io.tmpdir")); final File[] filesInTestFolder = testFolder.listFiles(); for (final File fileInTestFolder : filesInTestFolder) { if (!fileInTestFolder.getName().endsWith(".html")) { continue; } final String fileInTestFolderName = fileInTestFolder.getName(); final FileInputStream fileInTestFolderStream = new FileInputStream(fileInTestFolder); final InputStreamReader fileInTestFolderReader = new InputStreamReader(fileInTestFolderStream, "UTF-8"); final File testOutput = File.createTempFile("thymeleaf-testing-" + fileInTestFolderName + "-", ".html"); testOutput.deleteOnExit(); final FileOutputStream testOutputStream = new FileOutputStream(testOutput); final OutputStreamWriter testOutputWriter = new OutputStreamWriter(testOutputStream, "UTF-8"); final ITemplateHandler handler = new OutputTemplateHandler(fileInTestFolderName, testOutputWriter); System.out.print(fileInTestFolderName); System.out.print("[PARSING]"); PARSER.parse(TEMPLATE_ENGINE_CONTEXT, new ReaderResource(fileInTestFolderName, fileInTestFolderReader), handler); // Input stream will be closed by parser testOutputWriter.close(); testOutputStream.close(); System.out.print("[PARSED]"); final FileInputStream testOutputCheckStream = new FileInputStream(testOutput); final List<String> outputLines = IOUtils.readLines(testOutputCheckStream, "UTF-8"); final FileInputStream testInputCheckStream = new FileInputStream(fileInTestFolder); final List<String> inputLines = IOUtils.readLines(testInputCheckStream, "UTF-8"); System.out.print("[CHECKING]"); if (outputLines.equals(inputLines)) { System.out.print("[OK]"); } else { System.out.print("[KO]"); } System.out.println(); } }
From source file:org.thymeleaf.engine.HtmlBulkTester.java
public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Syntax: java " + HtmlBulkTester.class.getName() + " [test_folder]"); System.exit(1);// w ww . j a v a 2s . c om } final String testFolderName = args[0]; final File testFolder = new File(testFolderName); if (!testFolder.exists() || !testFolder.isDirectory()) { System.err.println("Folder " + testFolderName + " does not exist or is not a folder"); System.exit(1); } System.out.println("Using temporary folder for output: " + System.getProperty("java.io.tmpdir")); final File[] filesInTestFolder = testFolder.listFiles(); for (final File fileInTestFolder : filesInTestFolder) { if (!fileInTestFolder.getName().endsWith(".html")) { continue; } final String fileInTestFolderName = fileInTestFolder.getName(); final FileInputStream fileInTestFolderStream = new FileInputStream(fileInTestFolder); final InputStreamReader fileInTestFolderReader = new InputStreamReader(fileInTestFolderStream, "UTF-8"); final File testOutput = File.createTempFile("thymeleaf-testing-" + fileInTestFolderName + "-", ".html"); testOutput.deleteOnExit(); final FileOutputStream testOutputStream = new FileOutputStream(testOutput); final OutputStreamWriter testOutputWriter = new OutputStreamWriter(testOutputStream, "UTF-8"); final ITemplateHandler handler = new OutputTemplateHandler(testOutputWriter); handler.setProcessingContext(new ProcessingContext(TEMPLATE_ENGINE_CONFIGURATION, fileInTestFolderName, TemplateMode.HTML, Locale.US, null)); System.out.print(fileInTestFolderName); System.out.print("[PARSING]"); PARSER.parse(TEMPLATE_ENGINE_CONFIGURATION, TemplateMode.HTML, new ReaderResource(fileInTestFolderName, fileInTestFolderReader), handler); // Input stream will be closed by parser testOutputWriter.close(); testOutputStream.close(); System.out.print("[PARSED]"); final FileInputStream testOutputCheckStream = new FileInputStream(testOutput); final List<String> outputLines = IOUtils.readLines(testOutputCheckStream, "UTF-8"); final FileInputStream testInputCheckStream = new FileInputStream(fileInTestFolder); final List<String> inputLines = IOUtils.readLines(testInputCheckStream, "UTF-8"); System.out.print("[CHECKING]"); if (outputLines.equals(inputLines)) { System.out.print("[OK]"); } else { System.out.print("[KO]"); } System.out.println(); } }
From source file:Main.java
public static boolean isMonotonous(List<Integer> aList) { return aList.equals(sort(aList)) || aList.equals(reverse(sort(aList))); }
From source file:Main.java
public static <E> boolean containsSequence(List<E> list, List<E> sequence) { for (int i = 0; i < list.size() && i + sequence.size() <= list.size(); i++) { List<E> sublist = list.subList(i, i + sequence.size()); if (sublist.equals(sequence)) { return true; }//from w w w . j ava 2 s . c om } return false; }
From source file:Main.java
public static <E> boolean isSublistOf(List<E> bigger, List<E> smaller) { if (smaller.size() > bigger.size()) return false; for (int start = 0; start + smaller.size() <= bigger.size(); ++start) { List<E> sublist = bigger.subList(start, start + smaller.size()); if (sublist.equals(bigger)) { return true; }/* w w w . ja va 2s .c om*/ } return false; }
From source file:Main.java
public static <E> boolean isSublistOf(List<E> bigger, List<E> smaller) { if (smaller.size() > bigger.size()) { return false; }/*ww w. j a va 2 s.co m*/ for (int start = 0; start + smaller.size() <= bigger.size(); ++start) { List<E> sublist = bigger.subList(start, start + smaller.size()); if (sublist.equals(bigger)) { return true; } } return false; }
From source file:net.bcsw.sdnwlan.IngressVlans.java
/** * Build up the traffic treatment and selector for a flow's vlans * * @param selector/* w w w. ja va2s .com*/ * @param ingress * @param egress * @return */ public static TrafficTreatment.Builder vlanMatchAndTreatment(TrafficSelector.Builder selector, SDNWLANConnectPoint ingress, SDNWLANConnectPoint egress) { TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); // Always match any ingress vlans. The input VLAN list is arranged with outermost tag first List<VlanId> ingressVlans = ingress.getIngressVlans().getVlanList(); ingressVlans.forEach(vid -> selector.matchVlanId(vid)); // If egress vlans not equal to ingress, some type of action is required List<VlanId> egressVlans = egress.getIngressVlans().getVlanList(); if (!egressVlans.equals(ingressVlans)) { // Do simple push/pop all checks cases first if (ingressVlans.size() == 0) { // Push all egress vlans egressVlans.forEach(vid -> treatment.pushVlan().setVlanId(vid)); } else if (egressVlans.size() == 0) { // Pop all ingress vlans ingressVlans.forEach(vid -> treatment.popVlan()); } else { // TODO: Implement this more complex case } } return treatment; }
From source file:org.gradoop.flink.model.impl.operators.matching.single.cypher.common.pojos.EmbeddingTestUtils.java
/** * Checks if the given data set contains at least one embedding that matches the given path. * * @param embeddings data set containing embedding * @param path expected path//from w ww. ja v a 2 s . co m * @throws Exception */ public static void assertEmbeddingExists(DataSet<Embedding> embeddings, GradoopId... path) throws Exception { List<GradoopId> pathList = Lists.newArrayList(path); assertTrue( embeddings.collect().stream().anyMatch(embedding -> pathList.equals(embeddingToIdList(embedding)))); }