use of javax.annotation.Nonnull in project MinecraftForge by MinecraftForge.
the class ItemStackHandler method insertItem.
@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (stack.isEmpty())
return ItemStack.EMPTY;
validateSlotIndex(slot);
ItemStack existing = this.stacks.get(slot);
int limit = getStackLimit(slot, stack);
if (!existing.isEmpty()) {
if (!ItemHandlerHelper.canItemStacksStack(stack, existing))
return stack;
limit -= existing.getCount();
}
if (limit <= 0)
return stack;
boolean reachedLimit = stack.getCount() > limit;
if (!simulate) {
if (existing.isEmpty()) {
this.stacks.set(slot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
} else {
existing.grow(reachedLimit ? limit : stack.getCount());
}
onContentsChanged(slot);
}
return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
}
use of javax.annotation.Nonnull in project MinecraftForge by MinecraftForge.
the class VanillaDoubleChestItemHandler method insertItem.
@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
TileEntityChest chest = getChest(accessingUpperChest);
return chest != null ? chest.getSingleChestHandler().insertItem(targetSlot, stack, simulate) : stack;
}
use of javax.annotation.Nonnull in project MinecraftForge by MinecraftForge.
the class VanillaDoubleChestItemHandler method getStackInSlot.
@Override
@Nonnull
public ItemStack getStackInSlot(int slot) {
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
TileEntityChest chest = getChest(accessingUpperChest);
return chest != null ? chest.getStackInSlot(targetSlot) : ItemStack.EMPTY;
}
use of javax.annotation.Nonnull in project sonarqube by SonarSource.
the class WsCallAndWait method call.
@Nonnull
public RESPONSE call() {
String response = orchestrator.getServer().wsClient().post(targetRelativeUrl);
JSONObject jsonObject = toJsonObject(response);
try {
return parse(jsonObject);
} catch (Exception e) {
throw new IllegalStateException("Failed to parse JSON response", e);
}
}
use of javax.annotation.Nonnull in project atlas by alibaba.
the class PatchFieldTool method addField.
public static void addField(String inFile, String outFile, DexBackedClassDef dexBackedClassDef, ImmutableField immutableField) throws IOException {
DexFile dexFile = readDexFile(inFile);
for (ClassDef classDef : dexFile.getClasses()) {
if (dexBackedClassDef != null && dexBackedClassDef.getType().equals(classDef.getType())) {
dexFile = addField(dexFile, classDef.getType(), immutableField);
} else if (dexBackedClassDef == null) {
dexFile = addField(dexFile, classDef.getType(), immutableField);
}
}
reDexFile(dexFile);
DexFileFactory.writeDexFile(outFile, new DexFile() {
@Nonnull
@Override
public Set<? extends ClassDef> getClasses() {
return new AbstractSet<ClassDef>() {
@Nonnull
@Override
public Iterator<ClassDef> iterator() {
return classes.iterator();
}
@Override
public int size() {
return classes.size();
}
};
}
});
}
Aggregations