Search in sources :

Example 26 with Nonnull

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;
}
Also used : ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 27 with Nonnull

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;
}
Also used : TileEntityChest(net.minecraft.tileentity.TileEntityChest) Nonnull(javax.annotation.Nonnull)

Example 28 with Nonnull

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;
}
Also used : TileEntityChest(net.minecraft.tileentity.TileEntityChest) Nonnull(javax.annotation.Nonnull)

Example 29 with Nonnull

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);
    }
}
Also used : JSONObject(org.sonar.wsclient.jsonsimple.JSONObject) Nonnull(javax.annotation.Nonnull)

Example 30 with Nonnull

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();
                }
            };
        }
    });
}
Also used : DexBackedClassDef(org.jf.dexlib2.dexbacked.DexBackedClassDef) ImmutableClassDef(org.jf.dexlib2.immutable.ImmutableClassDef) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)2624 Nullable (javax.annotation.Nullable)338 ArrayList (java.util.ArrayList)336 ItemStack (net.minecraft.item.ItemStack)327 List (java.util.List)305 Map (java.util.Map)229 Layer (com.simiacryptus.mindseye.lang.Layer)188 Tensor (com.simiacryptus.mindseye.lang.Tensor)185 Arrays (java.util.Arrays)182 Collectors (java.util.stream.Collectors)169 IOException (java.io.IOException)165 JsonObject (com.google.gson.JsonObject)156 HashMap (java.util.HashMap)145 IntStream (java.util.stream.IntStream)145 Test (org.junit.Test)143 LoggerFactory (org.slf4j.LoggerFactory)138 Logger (org.slf4j.Logger)137 Result (com.simiacryptus.mindseye.lang.Result)130 TensorList (com.simiacryptus.mindseye.lang.TensorList)123 DeltaSet (com.simiacryptus.mindseye.lang.DeltaSet)111