use of java.util.AbstractMap.SimpleImmutableEntry in project bndtools by bndtools.
the class MavenWorkspaceRepository method mavenProjectChanged.
@Override
public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) {
if (events == null)
return;
for (MavenProjectChangedEvent event : events) {
final IMavenProjectFacade oldProject = event.getOldMavenProject();
final Iterator<Entry<String, Entry<IMavenProjectFacade, MavenProject>>> entries = bsnMap.entrySet().iterator();
while (entries.hasNext()) {
final Entry<String, Entry<IMavenProjectFacade, MavenProject>> entry = entries.next();
if (entry.getValue().getKey().equals(oldProject)) {
String bsn = entry.getKey();
bsnMap.remove(bsn);
break;
}
}
final IMavenProjectFacade newProject = event.getMavenProject();
try {
final MavenProject newMavenProject = getMavenProject(newProject, monitor);
final String newBsn = getBsnFromMavenProject(newMavenProject);
final Entry<IMavenProjectFacade, MavenProject> newEntry = new SimpleImmutableEntry<>(newProject, newMavenProject);
bsnMap.put(newBsn, newEntry);
} catch (Exception e) {
logger.logError("Error getting bsn for new project " + newProject.getProject().getName(), e);
}
}
}
use of java.util.AbstractMap.SimpleImmutableEntry in project buck by facebook.
the class AppleCoreSimulatorServiceControllerTest method coreSimulatorServicesKilledSuccessfully.
@Test
public void coreSimulatorServicesKilledSuccessfully() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(LAUNCHCTL_LIST_PARAMS, new FakeProcess(0, "87823\t0\tcom.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy\n" + "74617\t0\tcom.apple.CoreSimulator.SimDevice.CC1B0BAD-BAE6-4A53-92CF-F79850654057" + ".launchd_sim\n" + "74614\t0\tcom.apple.iphonesimulator.6564\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.SimDevice.CC1B0BAD-BAE6-4A53-92CF-F79850654057." + "launchd_sim")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.iphonesimulator.6564")).build(), new FakeProcess(0)));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleCoreSimulatorServiceController appleCoreSimulatorServiceController = new AppleCoreSimulatorServiceController(fakeProcessExecutor);
assertThat(appleCoreSimulatorServiceController.killSimulatorProcesses(), is(true));
}
use of java.util.AbstractMap.SimpleImmutableEntry in project buck by facebook.
the class AppleSimulatorControllerTest method startingSimulatorWorksWhenSimulatorAlreadyBooted.
@Test
public void startingSimulatorWorksWhenSimulatorAlreadyBooted() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0, " iPhone 5 (45BD7164-686C-474F-8C68-3730432BC5F2) (Shutdown)\n" + " iPhone 5s (70200ED8-EEF1-4BDB-BCCF-3595B137D67D) (Booted)\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("open", "-a", IOS_SIMULATOR_PATH.toString(), "--args", "-CurrentDeviceUDID", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0, " iPhone 5 (45BD7164-686C-474F-8C68-3730432BC5F2) (Shutdown)\n" + " iPhone 5s (70200ED8-EEF1-4BDB-BCCF-3595B137D67D) (Booted)\n", "")));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> result = appleSimulatorController.startSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", 1000);
assertThat(result, is(Optional.of(0L)));
}
use of java.util.AbstractMap.SimpleImmutableEntry in project storio by pushtorefresh.
the class PreparedDeleteCollectionOfObjects method executeAsBlocking.
/**
* Executes Delete Operation immediately in current thread.
* <p>
* Notice: This is blocking I/O operation that should not be executed on the Main Thread,
* it can cause ANR (Activity Not Responding dialog), block the UI and drop animations frames.
* So please, call this method on some background thread. See {@link WorkerThread}.
*
* @return non-null results of Delete Operation.
*/
@SuppressWarnings("unchecked")
@WorkerThread
@NonNull
@Override
public DeleteResults<T> executeAsBlocking() {
try {
final StorIOSQLite.LowLevel lowLevel = storIOSQLite.lowLevel();
// Nullable
final List<SimpleImmutableEntry<T, DeleteResolver<T>>> objectsAndDeleteResolvers;
if (explicitDeleteResolver != null) {
objectsAndDeleteResolvers = null;
} else {
objectsAndDeleteResolvers = new ArrayList<SimpleImmutableEntry<T, DeleteResolver<T>>>(objects.size());
for (final T object : objects) {
final SQLiteTypeMapping<T> typeMapping = (SQLiteTypeMapping<T>) lowLevel.typeMapping(object.getClass());
if (typeMapping == null) {
throw new IllegalStateException("One of the objects from the collection does not have type mapping: " + "object = " + object + ", object.class = " + object.getClass() + "," + "db was not affected by this operation, please add type mapping for this type");
}
objectsAndDeleteResolvers.add(new SimpleImmutableEntry<T, DeleteResolver<T>>(object, typeMapping.deleteResolver()));
}
}
if (useTransaction) {
lowLevel.beginTransaction();
}
final Map<T, DeleteResult> results = new HashMap<T, DeleteResult>(objects.size());
boolean transactionSuccessful = false;
try {
if (explicitDeleteResolver != null) {
for (final T object : objects) {
final DeleteResult deleteResult = explicitDeleteResolver.performDelete(storIOSQLite, object);
results.put(object, deleteResult);
if (!useTransaction && deleteResult.numberOfRowsDeleted() > 0) {
lowLevel.notifyAboutChanges(Changes.newInstance(deleteResult.affectedTables()));
}
}
} else {
for (final SimpleImmutableEntry<T, DeleteResolver<T>> objectAndDeleteResolver : objectsAndDeleteResolvers) {
final T object = objectAndDeleteResolver.getKey();
final DeleteResolver<T> deleteResolver = objectAndDeleteResolver.getValue();
final DeleteResult deleteResult = deleteResolver.performDelete(storIOSQLite, object);
results.put(object, deleteResult);
if (!useTransaction && deleteResult.numberOfRowsDeleted() > 0) {
lowLevel.notifyAboutChanges(Changes.newInstance(deleteResult.affectedTables()));
}
}
}
if (useTransaction) {
lowLevel.setTransactionSuccessful();
transactionSuccessful = true;
}
} finally {
if (useTransaction) {
lowLevel.endTransaction();
// if delete was in transaction and it was successful -> notify about changes
if (transactionSuccessful) {
// in most cases it will be one table
final Set<String> affectedTables = new HashSet<String>(1);
for (final T object : results.keySet()) {
final DeleteResult deleteResult = results.get(object);
if (deleteResult.numberOfRowsDeleted() > 0) {
affectedTables.addAll(results.get(object).affectedTables());
}
}
// It'll reduce number of possible deadlock situations
if (!affectedTables.isEmpty()) {
lowLevel.notifyAboutChanges(Changes.newInstance(affectedTables));
}
}
}
}
return DeleteResults.newInstance(results);
} catch (Exception exception) {
throw new StorIOException("Error has occurred during Delete operation. objects = " + objects, exception);
}
}
use of java.util.AbstractMap.SimpleImmutableEntry in project es6draft by anba.
the class CodeGenerator method compile.
Entry<MethodName, LabelState> compile(StatementListMethod node, CodeVisitor mv) {
if (!isCompiled(node)) {
MethodCode method = newMethod(mv.getTopLevelNode(), node);
StatementListMethodCodeVisitor body = new StatementListMethodCodeVisitor(node, method, mv);
body.lineInfo(node);
// force line-number entry
body.nop();
body.begin();
GeneratorState generatorState = null;
if (node.hasResumePoint()) {
generatorState = body.generatorPrologue();
}
body.labelPrologue();
Completion result = statements(node.getStatements(), body);
if (!result.isAbrupt()) {
// fall-thru, return `0`.
body.iconst(0);
body._return();
}
LabelState labelState = body.labelEpilogue(result);
if (generatorState != null) {
body.generatorEpilogue(generatorState);
}
body.end();
statementCompletions.put(node, labelState);
}
return new SimpleImmutableEntry<>(methodDesc(node), statementCompletions.get(node));
}
Aggregations