use of java.util.Map.Entry in project BluePower by Qmunity.
the class GateTransceiver method propagate.
@Override
public Collection<Entry<IConnection<IRedstoneDevice>, Boolean>> propagate(ForgeDirection fromSide) {
List<Entry<IConnection<IRedstoneDevice>, Boolean>> l = new ArrayList<Entry<IConnection<IRedstoneDevice>, Boolean>>();
if (frequency == null)
return l;
l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(getRedstoneConnectionCache().getConnectionOnSide(fromSide), false));
for (IWirelessDevice d : WirelessManager.COMMON_INSTANCE.getDevices()) {
if (d != this && d.getFrequency() != null && d.getFrequency().equals(getFrequency())) {
if (d instanceof GateTransceiver) {
IConnection<IRedstoneDevice> c = ((GateTransceiver) d).getRedstoneConnectionCache().getConnectionOnSide(((GateTransceiver) d).front().getForgeDirection());
if (c != null)
l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(c, false));
}
}
}
return l;
}
use of java.util.Map.Entry in project LogisticsPipes by RS485.
the class ModuleCCBasedQuickSort method handleSinkResponses.
private void handleSinkResponses(IInventoryUtil invUtil) {
boolean changed = false;
Iterator<Entry<Integer, Pair<Integer, List<CCSinkResponder>>>> iter = sinkResponses.entrySet().iterator();
while (iter.hasNext()) {
Entry<Integer, Pair<Integer, List<CCSinkResponder>>> pair = iter.next();
pair.getValue().setValue1(pair.getValue().getValue1() + 1);
boolean canBeHandled = true;
for (CCSinkResponder response : pair.getValue().getValue2()) {
if (!response.isDone()) {
canBeHandled = false;
break;
}
}
if (canBeHandled || pair.getValue().getValue1() > timeout) {
// skip entry, if slot is not in the inventory (too high).
boolean slotInInventory = pair.getKey() < invUtil.getSizeInventory();
if (slotInInventory && handle(invUtil, pair.getKey(), pair.getValue().getValue2())) {
stalled = false;
lastSuceededStack = pair.getKey();
}
iter.remove();
changed = true;
}
}
if (changed) {
checkSize();
}
}
use of java.util.Map.Entry in project LogisticsPipes by RS485.
the class PipeItemsProviderLogistics method getAllItems.
@Override
public void getAllItems(Map<ItemIdentifier, Integer> items, List<IFilter> filters) {
if (!isEnabled()) {
return;
}
HashMap<ItemIdentifier, Integer> addedItems = new HashMap<>();
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(container);
//@formatter:off
Iterator<Map<ItemIdentifier, Integer>> iterator = worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IInventory).filter(adjacent -> !SimpleServiceLocator.pipeInformationManager.isItemPipe(adjacent.tileEntity)).map(adjacent -> getAdaptedInventoryUtil(adjacent).getItemsAndCount()).iterator();
outer: while (iterator.hasNext()) {
Iterator<Entry<ItemIdentifier, Integer>> entryIterator = iterator.next().entrySet().stream().filter(currentItem -> !items.containsKey(currentItem.getKey())).filter(currentItem -> !hasFilter() || (!isExcludeFilter() || !itemIsFiltered(currentItem.getKey())) && (isExcludeFilter() || itemIsFiltered(currentItem.getKey()))).iterator();
while (entryIterator.hasNext()) {
Entry<ItemIdentifier, Integer> next = entryIterator.next();
for (IFilter filter : filters) {
if (filter.isBlocked() == filter.isFilteredItem(next.getKey().getUndamaged()) || filter.blockProvider()) {
continue outer;
}
}
Integer addedAmount = addedItems.get(next.getKey());
if (addedAmount == null) {
addedItems.put(next.getKey(), next.getValue());
} else {
addedItems.put(next.getKey(), addedAmount + next.getValue());
}
}
}
// reduce what has been reserved, add.
for (Entry<ItemIdentifier, Integer> item : addedItems.entrySet()) {
int remaining = item.getValue() - _orderManager.totalItemsCountInOrders(item.getKey());
if (remaining < 1) {
continue;
}
items.put(item.getKey(), remaining);
}
}
use of java.util.Map.Entry in project che by eclipse.
the class DeletePackageFragmentRootChange method doDelete.
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
if (!confirmDeleteIfReferenced())
return new NullChange();
int resourceUpdateFlags = IResource.KEEP_HISTORY;
int jCoreUpdateFlags = IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;
//$NON-NLS-1$
pm.beginTask("", 2);
IPackageFragmentRoot root = getRoot();
IResource rootResource = root.getResource();
CompositeChange result = new CompositeChange(getName());
ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource);
IJavaProject[] referencingProjects = JavaElementUtil.getReferencingProjects(root);
HashMap<IFile, String> classpathFilesContents = new HashMap<IFile, String>();
for (int i = 0; i < referencingProjects.length; i++) {
IJavaProject javaProject = referencingProjects[i];
//$NON-NLS-1$
IFile classpathFile = javaProject.getProject().getFile(".classpath");
if (classpathFile.exists()) {
classpathFilesContents.put(classpathFile, getFileContents(classpathFile));
}
}
root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1));
rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1));
for (Iterator<Entry<IFile, String>> iterator = classpathFilesContents.entrySet().iterator(); iterator.hasNext(); ) {
Entry<IFile, String> entry = iterator.next();
IFile file = entry.getKey();
String contents = entry.getValue();
//Restore time stamps? This should probably be some sort of UndoTextFileChange.
TextFileChange classpathUndo = new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file);
classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents));
result.add(classpathUndo);
}
result.add(new UndoDeleteResourceChange(rootDescription));
pm.done();
return result;
}
use of java.util.Map.Entry in project netty by netty.
the class Http2FrameCodecTest method connectionHandlerShouldBeAddedBeforeFramingHandler.
@Test
public void connectionHandlerShouldBeAddedBeforeFramingHandler() {
Iterator<Entry<String, ChannelHandler>> iter = channel.pipeline().iterator();
while (iter.hasNext()) {
ChannelHandler handler = iter.next().getValue();
if (handler instanceof Http2ConnectionHandler) {
break;
}
}
assertTrue(iter.hasNext());
assertThat(iter.next().getValue(), instanceOf(Http2FrameCodec.class));
}
Aggregations