Java Code Examples for java.util.List#equals()
The following examples show how to use
java.util.List#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MappingGenerationTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Verifies that SystemFlavorMap is not affected by modification of * the Lists returned from getNativesForFlavor() and * getFlavorsForNative(). */ public static void test2() { DataFlavor df = new DataFlavor("text/plain-test2", null); String nat = "native2"; DataFlavor extraDf = new DataFlavor("text/test", null); List<String> natives = fm.getNativesForFlavor(df); natives.add("Should not be here"); java.util.List nativesNew = fm.getNativesForFlavor(df); if (natives.equals(nativesNew)) { System.err.println("orig=" + natives); System.err.println("new=" + nativesNew); throw new RuntimeException("Test failed"); } List<DataFlavor> flavors = fm.getFlavorsForNative(nat); flavors.add(extraDf); java.util.List flavorsNew = fm.getFlavorsForNative(nat); if (flavors.equals(flavorsNew)) { System.err.println("orig=" + flavors); System.err.println("new=" + flavorsNew); throw new RuntimeException("Test failed"); } }
Example 2
Source File: PresenceParser.java From Conversations with GNU General Public License v3.0 | 6 votes |
public void parseConferencePresence(PresencePacket packet, Account account) { final Conversation conversation = packet.getFrom() == null ? null : mXmppConnectionService.find(account, packet.getFrom().asBareJid()); if (conversation != null) { final MucOptions mucOptions = conversation.getMucOptions(); boolean before = mucOptions.online(); int count = mucOptions.getUserCount(); final List<MucOptions.User> tileUserBefore = mucOptions.getUsers(5); processConferencePresence(packet, conversation); final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5); if (!tileUserAfter.equals(tileUserBefore)) { mXmppConnectionService.getAvatarService().clear(mucOptions); } if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUserCount())) { mXmppConnectionService.updateConversationUi(); } else if (mucOptions.online()) { mXmppConnectionService.updateMucRosterUi(); } } }
Example 3
Source File: Arrrghs.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
void doArgumentCheck(String inArgs, String... expArgs) { Map<String, String> env = new HashMap<>(); env.put(JLDEBUG_KEY, "true"); TestResult tr = doExec(env, javaCmd, inArgs); System.out.println(tr); int sindex = tr.testOutput.indexOf("Command line args:"); if (sindex < 0) { System.out.println(tr); throw new RuntimeException("Error: no output"); } sindex++; // skip over the tag List<String> gotList = new ArrayList<>(); for (String x : tr.testOutput.subList(sindex, sindex + expArgs.length)) { String a[] = x.split("="); gotList.add(a[a.length - 1].trim()); } List<String> expList = Arrays.asList(expArgs); if (!gotList.equals(expList)) { System.out.println(tr); System.out.println("Expected args:"); System.out.println(expList); System.out.println("Obtained args:"); System.out.println(gotList); throw new RuntimeException("Error: args do not match"); } }
Example 4
Source File: Arrrghs.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
void doArgumentCheck(String inArgs, String... expArgs) { Map<String, String> env = new HashMap<>(); env.put(JLDEBUG_KEY, "true"); TestResult tr = doExec(env, javaCmd, inArgs); System.out.println(tr); int sindex = tr.testOutput.indexOf("Command line args:"); if (sindex < 0) { System.out.println(tr); throw new RuntimeException("Error: no output"); } sindex++; // skip over the tag List<String> gotList = new ArrayList<>(); for (String x : tr.testOutput.subList(sindex, sindex + expArgs.length)) { String a[] = x.split("="); gotList.add(a[a.length - 1].trim()); } List<String> expList = Arrays.asList(expArgs); if (!gotList.equals(expList)) { System.out.println(tr); System.out.println("Expected args:"); System.out.println(expList); System.out.println("Obtained args:"); System.out.println(gotList); throw new RuntimeException("Error: args do not match"); } }
Example 5
Source File: ImmutableTreeTranslator.java From netbeans with Apache License 2.0 | 6 votes |
protected final MethodTree rewriteChildren(MethodTree tree) { ModifiersTree mods = (ModifiersTree)translate(tree.getModifiers()); ExpressionTree restype = (ExpressionTree)translateClassRef(tree.getReturnType()); List<? extends TypeParameterTree> typarams = translateStable(tree.getTypeParameters()); List<? extends VariableTree> params = translateStable(tree.getParameters()); List<? extends ExpressionTree> thrown = translate(tree.getThrows()); ExpressionTree defaultValue = (ExpressionTree)translate(tree.getDefaultValue()); BlockTree body = (BlockTree)translate(tree.getBody()); if (restype!=tree.getReturnType() || !typarams.equals(tree.getTypeParameters()) || !params.equals(tree.getParameters()) || !thrown.equals(tree.getThrows()) || mods!=tree.getModifiers() || defaultValue!=tree.getDefaultValue() || body!=tree.getBody()) { if ((((JCModifiers) mods).flags & Flags.GENERATEDCONSTR) != 0) { mods = make.Modifiers(((JCModifiers) mods).flags & ~Flags.GENERATEDCONSTR, mods.getAnnotations()); } MethodTree n = make.Method(mods, tree.getName().toString(), restype, typarams, params, thrown, body, defaultValue); copyCommentTo(tree,n); copyPosTo(tree,n); tree = n; } return tree; }
Example 6
Source File: TabPanelPowerGrid.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public void update() { // Check if building list has changed. List<Building> tempBuildings = getBuildings(); if (!tempBuildings.equals(buildings)) { buildings = tempBuildings; powerScrollPane.validate(); } /* * int newSize = buildings.size(); if (size != newSize) { size = newSize; * buildings = * settlement.getBuildingManager().getBuildingsWithPowerGeneration(); * //Collections.sort(buildings); } else { List<Building> newBuildings = * settlement.getBuildingManager().getACopyOfBuildings(); if * (!buildings.equals(newBuildings)) { buildings = newBuildings; * //Collections.sort(buildings); } } */ fireTableDataChanged(); }
Example 7
Source File: ExpectedMessage.java From ArchUnit with Apache License 2.0 | 5 votes |
@Override public Result filterMatching(List<String> lines) { List<String> rest = new ArrayList<>(); for (String line : lines) { if (!expectedMessage.equals(line)) { rest.add(line); } } boolean matches = !lines.equals(rest); return new Result(matches, rest); }
Example 8
Source File: MappingGenerationTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Verifies that addUnencodedNativeForFlavor() for a particular text flavor * doesn't affect mappings for other flavors. */ public static void test3() { DataFlavor df1 = new DataFlavor("text/plain-test3", null); DataFlavor df2 = new DataFlavor("text/plain-test3; charset=Unicode; class=java.io.Reader", null); String nat = "native3"; List<String> natives = fm.getNativesForFlavor(df2); fm.addUnencodedNativeForFlavor(df1, nat); List<String> nativesNew = fm.getNativesForFlavor(df2); if (!natives.equals(nativesNew)) { System.err.println("orig=" + natives); System.err.println("new=" + nativesNew); throw new RuntimeException("Test failed"); } }
Example 9
Source File: ImmutableTreeTranslator.java From netbeans with Apache License 2.0 | 5 votes |
protected final ClassTree rewriteChildren(ClassTree tree) { ModifiersTree mods = (ModifiersTree)translate(tree.getModifiers()); List<? extends TypeParameterTree> typarams = translateStable(tree.getTypeParameters()); Tree extending = translateClassRef(tree.getExtendsClause()); List<? extends ExpressionTree> implementing = translateClassRef((List<? extends ExpressionTree>)tree.getImplementsClause()); importAnalysis.enterVisibleThroughClasses(tree); List<? extends Tree> defs = translate(tree.getMembers()); boolean typeChanged = !typarams.equals(tree.getTypeParameters()) || extending != tree.getExtendsClause() || !implementing.equals(tree.getImplementsClause()); if (typeChanged || mods != tree.getModifiers() || !defs.equals(tree.getMembers())) { ClassTree n = make.Class(mods, tree.getSimpleName(), typarams, extending, implementing, defs); if (!typeChanged) { model.setElement(n, model.getElement(tree)); model.setType(n, model.getType(tree)); } copyCommentTo(tree,n); if (tree.getMembers().size() == defs.size()) model.setPos(n, model.getPos(tree)); else copyPosTo(tree,n); tree = n; } return tree; }
Example 10
Source File: TestProvider.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void verifyOneInvocation(Method method, Object[] args, List invocationQueue) { TestProvider.Invocation inv = (TestProvider.Invocation) invocationQueue.remove(0); if (!method.equals(inv.method)) { throw new RuntimeException( "unexpected provider method invoked: expected " + method + ", detected " + inv.method); } List expectedArgs = Arrays.asList(args); List detectedArgs = Arrays.asList(inv.args); if (!expectedArgs.equals(detectedArgs)) { throw new RuntimeException("TEST FAILED: " + "unexpected provider method invocation arguments: " + "expected " + expectedArgs + ", detected " + detectedArgs); } if (!invocationQueue.isEmpty()) { inv = (TestProvider.Invocation) invocationQueue.remove(0); throw new RuntimeException("TEST FAILED: " + "unexpected provider invocation: " + inv.method + " " + Arrays.asList(inv.args)); } }
Example 11
Source File: StreamingServer.java From kylin with Apache License 2.0 | 5 votes |
public synchronized void startConsumer(String cubeName, ConsumerStartProtocol startProtocol) { List<Partition> partitions = assignments.get(cubeName); StreamingConsumerChannel consumer = cubeConsumerMap.get(cubeName); if (consumer != null) { List<Partition> consumingPartitions = consumer.getConsumePartitions(); Collections.sort(partitions); Collections.sort(consumingPartitions); if (partitions.equals(consumingPartitions)) { logger.info("The consumer for cube:{} is already running, skip starting", cubeName); } else { String msg = String .format(Locale.ROOT, "The running consumer for cube:%s partition:%s is conflict with assign partitions:%s, should stop the consumer first.", cubeName, consumingPartitions, partitions); throw new IllegalStateException(msg); } } else { if (partitions == null || partitions.isEmpty()) { logger.info("partitions is empty for cube:{}", cubeName); return; } logger.info("create and start new consumer for cube:{}", cubeName); try { reloadCubeMetadata(cubeName); StreamingConsumerChannel newConsumer = createNewConsumer(cubeName, partitions, startProtocol); newConsumer.start(); } catch (Exception e) { logger.error("consumer start fail for cube:" + cubeName, e); } } }
Example 12
Source File: AppServicesCapabilities.java From sdl_java_suite with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * This method will update the current List<AppServiceCapability> with the updated items. If the * items don't exist in the original ist they will be added. If the original list is null or * empty, the new list will simply be set as the list. * @param updatedAppServiceCapabilities the List<AppServiceCapability> that have been updated * @return if the list was updated */ public boolean updateAppServices(@NonNull List<AppServiceCapability> updatedAppServiceCapabilities){ if(updatedAppServiceCapabilities == null){ return false; } List<AppServiceCapability> appServiceCapabilities = getAppServices(); if(appServiceCapabilities == null){ //If there are currently no app services, create one to iterate over with no entries appServiceCapabilities = new ArrayList<>(0); } //Create a shallow copy for us to alter while iterating through the original list List<AppServiceCapability> tempList = new ArrayList<>(appServiceCapabilities); for(AppServiceCapability updatedAppServiceCapability: updatedAppServiceCapabilities){ if(updatedAppServiceCapability != null) { //First search if the record exists in the current list and remove it if so for (AppServiceCapability appServiceCapability : appServiceCapabilities) { if (updatedAppServiceCapability.matchesAppService(appServiceCapability)) { tempList.remove(appServiceCapability); //Remove the old entry break; } } if(!ServiceUpdateReason.REMOVED.equals(updatedAppServiceCapability.getUpdateReason())){ //If the app service was anything but removed, we can add the updated //record back into the temp list. If it was REMOVED as the update reason //it will not be added back. tempList.add(updatedAppServiceCapability); } } } setAppServices(tempList); return !tempList.equals(appServiceCapabilities); //Return if the list is not equal to the original }
Example 13
Source File: SoftMargins.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object obj) { if (obj instanceof SoftMargins) { List<Integer> otherMargins = ((SoftMargins)obj).getValues(); return otherMargins.equals(getValues()); } return false; }
Example 14
Source File: ParseNodeRewriter.java From phoenix with Apache License 2.0 | 5 votes |
protected ParseNode leaveCompoundNode(CompoundParseNode node, List<ParseNode> children, CompoundNodeFactory factory) { if (children.equals(node.getChildren())) { return node; } else { // Child nodes have been inverted (because a literal was found on LHS) return factory.createNode(children); } }
Example 15
Source File: Range.java From jlibs with Apache License 2.0 | 4 votes |
public static boolean same(List<Range> list1, List<Range> list2){ list1 = union(list1); list2 = union(list2); return list1.equals(list2); }
Example 16
Source File: EmptyScope.java From calcite with Apache License 2.0 | 4 votes |
private void resolve_(final CalciteSchema rootSchema, List<String> names, List<String> schemaNames, SqlNameMatcher nameMatcher, Path path, Resolved resolved) { final List<String> concat = ImmutableList.<String>builder() .addAll(schemaNames).addAll(names).build(); CalciteSchema schema = rootSchema; SqlValidatorNamespace namespace = null; List<String> remainingNames = concat; for (String schemaName : concat) { if (schema == rootSchema && nameMatcher.matches(schemaName, schema.name)) { remainingNames = Util.skip(remainingNames); continue; } final CalciteSchema subSchema = schema.getSubSchema(schemaName, nameMatcher.isCaseSensitive()); if (subSchema != null) { path = path.plus(null, -1, subSchema.name, StructKind.NONE); remainingNames = Util.skip(remainingNames); schema = subSchema; namespace = new SchemaNamespace(validator, ImmutableList.copyOf(path.stepNames())); continue; } CalciteSchema.TableEntry entry = schema.getTable(schemaName, nameMatcher.isCaseSensitive()); if (entry == null) { entry = schema.getTableBasedOnNullaryFunction(schemaName, nameMatcher.isCaseSensitive()); } if (entry != null) { path = path.plus(null, -1, entry.name, StructKind.NONE); remainingNames = Util.skip(remainingNames); final Table table = entry.getTable(); SqlValidatorTable table2 = null; if (table instanceof Wrapper) { table2 = ((Wrapper) table).unwrap(Prepare.PreparingTable.class); } if (table2 == null) { final RelOptSchema relOptSchema = validator.catalogReader.unwrap(RelOptSchema.class); final RelDataType rowType = table.getRowType(validator.typeFactory); table2 = RelOptTableImpl.create(relOptSchema, rowType, entry, null); } namespace = new TableNamespace(validator, table2); resolved.found(namespace, false, null, path, remainingNames); return; } // neither sub-schema nor table if (namespace != null && !remainingNames.equals(names)) { resolved.found(namespace, false, null, path, remainingNames); } return; } }
Example 17
Source File: TestPairSequenceRecordReaderBytesFunction.java From DataVec with Apache License 2.0 | 4 votes |
@Test public void test() throws Exception { //Goal: combine separate files together into a hadoop sequence file, for later parsing by a SequenceRecordReader //For example: use to combine input and labels data from separate files for training a RNN JavaSparkContext sc = getContext(); ClassPathResource cpr = new ClassPathResource("/video/shapes_0.mp4"); String path = cpr.getFile().getAbsolutePath(); String folder = path.substring(0, path.length() - 12); path = folder + "*"; PathToKeyConverter pathConverter = new PathToKeyConverterFilename(); JavaPairRDD<Text, BytesPairWritable> toWrite = DataVecSparkUtil.combineFilesForSequenceFile(sc, path, path, pathConverter); Path p = Files.createTempDirectory("dl4j_rrbytesPairOut"); p.toFile().deleteOnExit(); String outPath = p.toString() + "/out"; new File(outPath).deleteOnExit(); toWrite.saveAsNewAPIHadoopFile(outPath, Text.class, BytesPairWritable.class, SequenceFileOutputFormat.class); //Load back into memory: JavaPairRDD<Text, BytesPairWritable> fromSeq = sc.sequenceFile(outPath, Text.class, BytesPairWritable.class); SequenceRecordReader srr1 = getReader(); SequenceRecordReader srr2 = getReader(); PairSequenceRecordReaderBytesFunction psrbf = new PairSequenceRecordReaderBytesFunction(srr1, srr2); JavaRDD<Tuple2<List<List<Writable>>, List<List<Writable>>>> writables = fromSeq.map(psrbf); List<Tuple2<List<List<Writable>>, List<List<Writable>>>> fromSequenceFile = writables.collect(); //Load manually (single copy) and compare: InputSplit is = new FileSplit(new File(folder), new String[] {"mp4"}, true); SequenceRecordReader srr = getReader(); srr.initialize(is); List<List<List<Writable>>> list = new ArrayList<>(4); while (srr.hasNext()) { list.add(srr.sequenceRecord()); } assertEquals(4, list.size()); assertEquals(4, fromSequenceFile.size()); boolean[] found = new boolean[4]; for (int i = 0; i < 4; i++) { int foundIndex = -1; Tuple2<List<List<Writable>>, List<List<Writable>>> tuple2 = fromSequenceFile.get(i); List<List<Writable>> seq1 = tuple2._1(); List<List<Writable>> seq2 = tuple2._2(); assertEquals(seq1, seq2); for (int j = 0; j < 4; j++) { if (seq1.equals(list.get(j))) { if (foundIndex != -1) fail(); //Already found this value -> suggests this spark value equals two or more of local version? (Shouldn't happen) foundIndex = j; if (found[foundIndex]) fail(); //One of the other spark values was equal to this one -> suggests duplicates in Spark list found[foundIndex] = true; //mark this one as seen before } } } int count = 0; for (boolean b : found) if (b) count++; assertEquals(4, count); //Expect all 4 and exactly 4 pairwise matches between spark and local versions }
Example 18
Source File: MysqlSchemaManager.java From SpinalTap with Apache License 2.0 | 4 votes |
private boolean processTableSchemaChanges( String database, QueryEvent event, String gtid, Map<String, MysqlTableSchema> tableSchemaMapInSchemaStore, Map<String, List<MysqlColumn>> tableColumnsInSchemaDatabase) { boolean isTableColumnChanged = false; Set<String> deletedTables = Sets.difference(tableSchemaMapInSchemaStore.keySet(), tableColumnsInSchemaDatabase.keySet()) .immutableCopy(); for (String deletedTable : deletedTables) { schemaStore.put( new MysqlTableSchema( 0, database, deletedTable, event.getBinlogFilePos(), gtid, event.getSql(), event.getTimestamp(), Collections.emptyList(), Collections.emptyMap())); isTableColumnChanged = true; } for (Map.Entry<String, List<MysqlColumn>> tableColumns : tableColumnsInSchemaDatabase.entrySet()) { String table = tableColumns.getKey(); List<MysqlColumn> columns = tableColumns.getValue(); if (!tableSchemaMapInSchemaStore.containsKey(table) || !columns.equals(tableSchemaMapInSchemaStore.get(table).getColumns())) { schemaStore.put( new MysqlTableSchema( 0, database, table, event.getBinlogFilePos(), gtid, event.getSql(), event.getTimestamp(), columns, Collections.emptyMap())); isTableColumnChanged = true; } } return isTableColumnChanged; }
Example 19
Source File: FluxBufferPredicateTest.java From reactor-core with Apache License 2.0 | 4 votes |
@Test public void testBufferUntilNoExtraRequestFromConcurrentEmitAndRequest() { AtomicReference<Throwable> errorOrComplete = new AtomicReference<>(); ConcurrentLinkedQueue<List<Integer>> buffers = new ConcurrentLinkedQueue<>(); final BaseSubscriber<List<Integer>> subscriber = new BaseSubscriber<List<Integer>>() { @Override protected void hookOnSubscribe(Subscription subscription) { request(1); } @Override protected void hookOnNext(List<Integer> value) { buffers.add(value); if (value.equals(Collections.singletonList(0))) { request(1); } } @Override protected void hookOnError(Throwable throwable) { errorOrComplete.set(throwable); } @Override protected void hookFinally(SignalType type) { if (type != SignalType.ON_ERROR) { errorOrComplete.set(new IllegalArgumentException("Terminated with signal type " + type)); } } }; final CountDownLatch emitLatch = new CountDownLatch(1); Flux.just(0, 1, 2, 3, 4) .bufferUntil(s -> { if (s == 1) { try { Mono.fromRunnable(() -> { subscriber.request(1); emitLatch.countDown(); }) .subscribeOn(Schedulers.single()) .subscribe(); emitLatch.await(); } catch (InterruptedException e) { throw Exceptions.propagate(e); } } return true; }) .subscribe((Subscriber<? super List<Integer>>) subscriber); //sync subscriber, no need to sleep/latch assertThat(buffers).hasSize(3) .allMatch(b -> b.size() == 1, "size one"); //total requests: 3 assertThat(buffers.stream().flatMapToInt(l -> l.stream().mapToInt(Integer::intValue))) .containsExactly(0,1,2); assertThat(errorOrComplete.get()).isNull(); //request the rest subscriber.requestUnbounded(); assertThat(errorOrComplete.get()).isInstanceOf(IllegalArgumentException.class) .hasMessage("Terminated with signal type onComplete"); }
Example 20
Source File: IncubatingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test public void testDoNotResolve(Path base) throws Exception { Path src = base.resolve("src"); tb.writeJavaFiles(src, "module jdk.i { exports api; }", "package api; public class Api { }"); Path classes = base.resolve("classes"); Files.deleteIfExists(classes); Path iClasses = classes.resolve("jdk.i"); tb.createDirectories(iClasses); new JavacTask(tb) .outdir(iClasses) .files(findJavaFiles(src)) .run() .writeAll(); copyJavaBase(classes); Path jdkIModuleInfo = iClasses.resolve("module-info.class"); addModuleResolutionAttribute(jdkIModuleInfo, ModuleResolution_attribute.DO_NOT_RESOLVE_BY_DEFAULT); Path testSrc = base.resolve("test-src"); tb.writeJavaFiles(testSrc, "class T { api.Api api; }"); Path testClasses = base.resolve("test-classes"); tb.createDirectories(testClasses); List<String> log; List<String> expected; log = new JavacTask(tb) .options("--system", "none", "--upgrade-module-path", classes.toString(), "-XDrawDiagnostics") .outdir(testClasses) .files(findJavaFiles(testSrc)) .run(Expect.FAIL) .writeAll() .getOutputLines(Task.OutputKind.DIRECT); expected = Arrays.asList( "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)", "1 error" ); if (!expected.equals(log)) { throw new AssertionError("Unexpected output: " + log); } log = new JavacTask(tb) .options("--system", "none", "--upgrade-module-path", classes.toString(), "--add-modules", "ALL-SYSTEM", "-XDrawDiagnostics") .outdir(testClasses) .files(findJavaFiles(testSrc)) .run(Expect.SUCCESS) .writeAll() .getOutputLines(Task.OutputKind.DIRECT); expected = Arrays.asList(""); if (!expected.equals(log)) { throw new AssertionError("Unexpected output: " + log); } new JavacTask(tb) .options("--system", "none", "--upgrade-module-path", classes.toString(), "--add-modules", "jdk.i") .outdir(testClasses) .files(findJavaFiles(testSrc)) .run() .writeAll(); Path testModuleSrc = base.resolve("test-module-src"); tb.writeJavaFiles(testModuleSrc, "module test { requires jdk.i; }", //explicit requires of an incubating module "class T { api.Api api; }"); Path testModuleClasses = base.resolve("test-module-classes"); tb.createDirectories(testModuleClasses); new JavacTask(tb) .options("--system", "none", "--upgrade-module-path", classes.toString()) .outdir(testModuleClasses) .files(findJavaFiles(testModuleSrc)) .run() .writeAll(); }