ronantakizawa/codereview-bench huggingface dataset:
Repository: PaperMC/Paper
File: paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java (Java)

Code before:
package org.bukkit.craftbukkit.entity;

import io.papermc.paper.entity.PaperShearable;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.CopperGolem;

public class CraftCopperGolem extends CraftGolem implements CopperGolem, PaperShearable {
    public CraftCopperGolem(final CraftServer server, final net.minecraft.world.entity.animal.coppergolem.CopperGolem entity) {
        super(server, entity);
    }

    @Override
    public net.minecraft.world.entity.animal.coppergolem.CopperGolem getHandle() {
        return (net.minecraft.world.entity.animal.coppergolem.CopperGolem) this.entity;
    }
}


Review comment (suggestion):
This could be simplified using a switch expression then the default case can be removed too since you covered all the values.

Code after:

    @Override
    public void setWeatheringState(final WeatheringCopperState state) {
        Preconditions.checkArgument(state != null, "state cannot be null");
        this.getHandle().setWeatherState(WeatheringCopper.WeatherState.valueOf(state.name()));
    }

    @Override
    public Oxidizing getOxidizing() {
        long value = this.getHandle().nextWeatheringTick;
        if (value == net.minecraft.world.entity.animal.coppergolem.CopperGolem.UNSET_WEATHERING_TICK) {
            return Oxidizing.unset();
        } else if (value == net.minecraft.world.entity.animal.coppergolem.CopperGolem.IGNORE_WEATHERING_TICK) {
            return Oxidizing.waxed();
        }
        if (value < 0) {
            // If someone set the entity data negative externally - the behavior is effectively the same as 0 (check is <= gameTime)
            value = 0;
        }
        return Oxidizing.atTime(value);
    }

    @Override
    public void setOxidizing(final Oxidizing oxidizing) {
        Preconditions.checkArgument(oxidizing != null, "oxidizing cannot be null");
        switch (oxidizing) {
            case Oxidizing.Waxed waxed -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.coppergolem.CopperGolem.IGNORE_WEATHERING_TICK;
            case Oxidizing.Unset unset -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.coppergolem.CopperGolem.UNSET_WEATHERING_TICK;
            case Oxidizing.AtTime atTime -> this.getHandle().nextWeatheringTick = atTime.time();
            default -> throw new IllegalStateException("Unexpected value: " + oxidizing);
        }
    }
}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java (Java)

Code before:
         * When an Allay duplicate itself
         */
        DUPLICATION,
        /**
         * When a creature is spawned by the "/summon" command
         */
        COMMAND,
        /**
         * When a creature is spawned by an enchantment
         */
        ENCHANTMENT,
        /**
         * When an entity spawns from an ominous item spawner
         */
        OMINOUS_ITEM_SPAWNER,
        /**
         * When an entity spawns from a bucket
         */
        BUCKET,
        /**
         * When a creature is spawned by a potion effect, for example:
         * {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED}
         */
        POTION_EFFECT,
        /**
         * When a copper golem statue is turned back into a copper golem
         *
         * @apiNote Cancel an {@link CreatureSpawnEvent} with this reason not avoid the statue block to being change, you need to use {@link EntityChangeBlockEvent} for that
         */
        REANIMATE,
        /**
         * When a creature is spawned by being rehydrated
         */
        REHYDRATION,
        /**
         * When a creature is spawned by plugins
         */
        CUSTOM,
        /**
         * When an entity is missing a SpawnReason
         */
        DEFAULT
    }
}


Review comment (suggestion):
```suggestion
         * When a Copper Golem Statue turns back into a Copper Golem
```

Code after:
         * When an Allay duplicate itself
         */
        DUPLICATION,
        /**
         * When a creature is spawned by the "/summon" command
         */
        COMMAND,
        /**
         * When a creature is spawned by an enchantment
         */
        ENCHANTMENT,
        /**
         * When an entity spawns from an ominous item spawner
         */
        OMINOUS_ITEM_SPAWNER,
        /**
         * When an entity spawns from a bucket
         */
        BUCKET,
        /**
         * When a creature is spawned by a potion effect, for example:
         * {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED}
         */
        POTION_EFFECT,
        /**
         * When a Copper Golem Statue turns back into a Copper Golem
         *
         * @apiNote Canceling a {@link CreatureSpawnEvent} with this reason does not prevent the statue block from being removed, use {@link EntityChangeBlockEvent} to account for all side effects
         */
        REANIMATE,
        /**
         * When a creature is spawned by being rehydrated
         */
        REHYDRATION,
        /**
         * When a creature is spawned by plugins
         */
        CUSTOM,
        /**
         * When an entity is missing a SpawnReason
         */
        DEFAULT
    }
}
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java (Java)

Code before:
        DUPLICATION,
        /**
         * When a creature is spawned by the "/summon" command
         */
        COMMAND,
        /**
         * When a creature is spawned by an enchantment
         */
        ENCHANTMENT,
        /**
         * When an entity spawns from an ominous item spawner
         */
        OMINOUS_ITEM_SPAWNER,
        /**
         * When an entity spawns from a bucket
         */
        BUCKET,
        /**
         * When a creature is spawned by a potion effect, for example:
         * {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED}
         */
        POTION_EFFECT,
        /**
         * When a copper golem statue is turned back into a copper golem
         *
         * @apiNote Cancel an {@link CreatureSpawnEvent} with this reason not avoid the statue block to being change, you need to use {@link EntityChangeBlockEvent} for that
         */
        REANIMATE,
        /**
         * When a creature is spawned by being rehydrated
         */
        REHYDRATION,
        /**
         * When a creature is spawned by plugins
         */
        CUSTOM,
        /**
         * When an entity is missing a SpawnReason
         */
        DEFAULT
    }
}


Review comment (suggestion):
```suggestion
         * @apiNote Canceling a {@link CreatureSpawnEvent} with this reason does not prevent the statue block from being removed, use {@link EntityChangeBlockEvent} to account for all side effects
```

Code after:
        DUPLICATION,
        /**
         * When a creature is spawned by the "/summon" command
         */
        COMMAND,
        /**
         * When a creature is spawned by an enchantment
         */
        ENCHANTMENT,
        /**
         * When an entity spawns from an ominous item spawner
         */
        OMINOUS_ITEM_SPAWNER,
        /**
         * When an entity spawns from a bucket
         */
        BUCKET,
        /**
         * When a creature is spawned by a potion effect, for example:
         * {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED}
         */
        POTION_EFFECT,
        /**
         * When a Copper Golem Statue turns back into a Copper Golem
         *
         * @apiNote Canceling a {@link CreatureSpawnEvent} with this reason does not prevent the statue block from being removed, use {@link EntityChangeBlockEvent} to account for all side effects
         */
        REANIMATE,
        /**
         * When a creature is spawned by being rehydrated
         */
        REHYDRATION,
        /**
         * When a creature is spawned by plugins
         */
        CUSTOM,
        /**
         * When an entity is missing a SpawnReason
         */
        DEFAULT
    }
}
Repository: PaperMC/Paper
File: paper-api/src/main/java/io/papermc/paper/persistence/PersistentDataContainerView.java (Java)

Code before:
     * @param other the container to copy to
     * @param replace whether to replace any matching values in the target container
     * @throws IllegalArgumentException if the other container is null
     */
    void copyTo(PersistentDataContainer other, boolean replace);

    /**
     * Returns the adapter context this tag container uses.
     *
     * @return the tag context
     */
    PersistentDataAdapterContext getAdapterContext();

    /**
     * Serialize this {@link PersistentDataContainer} instance to a
     * byte array.
     *
     * @return a binary representation of this container
     * @throws java.io.IOException if we fail to write this container to a byte array
     */
    byte[] serializeToBytes() throws java.io.IOException;

    /**
     * Returns the size of the data container
     *
     * @return The size of the data container
     */
    int getSize();
}


Review comment (suggestion):
This can also be written as, renders to the same thing
```suggestion
     * {@return the size of the data container}
```

Code after:
     * @param other the container to copy to
     * @param replace whether to replace any matching values in the target container
     * @throws IllegalArgumentException if the other container is null
     */
    void copyTo(PersistentDataContainer other, boolean replace);

    /**
     * Returns the adapter context this tag container uses.
     *
     * @return the tag context
     */
    PersistentDataAdapterContext getAdapterContext();

    /**
     * Serialize this {@link PersistentDataContainer} instance to a
     * byte array.
     *
     * @return a binary representation of this container
     * @throws java.io.IOException if we fail to write this container to a byte array
     */
    byte[] serializeToBytes() throws java.io.IOException;

    /**
     * {@return the size of the data container}
     */
    int getSize();
}
Repository: PaperMC/Paper
File: paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java (Java)

Code before:
package org.bukkit.craftbukkit.help;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.help.HelpMap;
import org.bukkit.help.HelpTopic;
import org.bukkit.help.IndexHelpTopic;

public class CustomIndexHelpTopic extends IndexHelpTopic {
    private List<String> futureTopics;
    private final HelpMap helpMap;

    public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) {
        super(name, shortText, permission, new HashSet<>(), preamble);
        this.helpMap = helpMap;
        this.futureTopics = futureTopics;
    }

    @Override
    public String getFullText(CommandSender sender) {
        if (this.futureTopics != null) {
            List<HelpTopic> topics = new LinkedList<>();
            for (String futureTopic : this.futureTopics) {
                HelpTopic topic = this.helpMap.getHelpTopic(futureTopic);
                if (topic != null) {
                    topics.add(topic);
                }
            }
            this.setTopicsCollection(topics);
            this.futureTopics = null;
        }

        return super.getFullText(sender);

Review comment (suggestion):
```suggestion
import org.jspecify.annotations.NonNull;
```
You should use the jspecify annotations in this case

Code after:
package org.bukkit.craftbukkit.help;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.help.HelpMap;
import org.bukkit.help.HelpTopic;
import org.bukkit.help.IndexHelpTopic;
import org.jetbrains.annotations.NotNull;

public class CustomIndexHelpTopic extends IndexHelpTopic {
    private List<String> futureTopics;
    private final HelpMap helpMap;

    public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) {
        super(name, shortText, permission, new HashSet<>(), preamble);
        this.helpMap = helpMap;
        this.futureTopics = futureTopics;
    }

    @Override
    public boolean canSee(@NotNull final CommandSender sender) {
        this.computeTopics();

        return super.canSee(sender);
    }

    @Override
    public String getFullText(CommandSender sender) {
        this.computeTopics();

        return super.getFullText(sender);
    }
Repository: PaperMC/Paper
File: paper-server/src/main/java/org/bukkit/craftbukkit/help/CustomIndexHelpTopic.java (Java)

Code before:
package org.bukkit.craftbukkit.help;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.help.HelpMap;
import org.bukkit.help.HelpTopic;
import org.bukkit.help.IndexHelpTopic;

public class CustomIndexHelpTopic extends IndexHelpTopic {
    private List<String> futureTopics;
    private final HelpMap helpMap;

    public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) {
        super(name, shortText, permission, new HashSet<>(), preamble);
        this.helpMap = helpMap;
        this.futureTopics = futureTopics;
    }

    @Override
    public String getFullText(CommandSender sender) {
        if (this.futureTopics != null) {
            List<HelpTopic> topics = new LinkedList<>();
            for (String futureTopic : this.futureTopics) {
                HelpTopic topic = this.helpMap.getHelpTopic(futureTopic);
                if (topic != null) {
                    topics.add(topic);
                }
            }
            this.setTopicsCollection(topics);
            this.futureTopics = null;
        }

        return super.getFullText(sender);
    }
}


Review comment (suggestion):
```suggestion
    public boolean canSee(@NonNull final CommandSender sender) {
```

Code after:
package org.bukkit.craftbukkit.help;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.help.HelpMap;
import org.bukkit.help.HelpTopic;
import org.bukkit.help.IndexHelpTopic;
import org.jetbrains.annotations.NotNull;

public class CustomIndexHelpTopic extends IndexHelpTopic {
    private List<String> futureTopics;
    private final HelpMap helpMap;

    public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) {
        super(name, shortText, permission, new HashSet<>(), preamble);
        this.helpMap = helpMap;
        this.futureTopics = futureTopics;
    }

    @Override
    public boolean canSee(@NotNull final CommandSender sender) {
        this.computeTopics();

        return super.canSee(sender);
    }

    @Override
    public String getFullText(CommandSender sender) {
        this.computeTopics();

        return super.getFullText(sender);
    }

    private void computeTopics() {
        if (this.futureTopics != null) {
            List<HelpTopic> topics = new LinkedList<>();
            for (String futureTopic : this.futureTopics) {
                HelpTopic topic = this.helpMap.getHelpTopic(futureTopic);
                if (topic != null) {
                    topics.add(topic);
                }
            }
            this.setTopicsCollection(topics);
            this.futureTopics = null;
        }
    }
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/block/Crafter.java (Java)

Code before:
public interface Crafter extends Container, com.destroystokyo.paper.loottable.LootableBlockInventory { // Paper - LootTable API

    /**
     * Gets the number of ticks which this block will remain in the crafting
     * state for.
     *
     * @return number of ticks remaining
     * @see org.bukkit.block.data.type.Crafter#isCrafting()
     */
    int getCraftingTicks();

    /**
     * Sets the number of ticks which this block will remain in the crafting
     * state for.
     *
     * @param ticks number of ticks remaining
     * @see org.bukkit.block.data.type.Crafter#isCrafting()
     */
    void setCraftingTicks(int ticks);

    /**
     * Gets whether the slot at the specified index is disabled and will not
     * have items placed in it.
     *
     * @param slot slot index
     * @return true if the slot is disabled otherwise false
     */
    boolean isSlotDisabled(int slot);

    /**
     * Sets whether the slot at the specified index is disabled and will not
     * have items placed in it.
     *
     * @param slot slot index
     * @param disabled true if the slot should be disabled otherwise false
     */
    void setSlotDisabled(int slot, boolean disabled);

    /**
     * Gets whether this Crafter is powered.
     *
     * @return powered status
     */
    boolean isTriggered();

    /**
     * Sets whether this Crafter is powered.
     *
     * @param triggered powered status
     */
    void setTriggered(boolean triggered);

Review comment (suggestion):
```suggestion
     * @return whether the slot is disabled
```

Code after:
public interface Crafter extends Container, com.destroystokyo.paper.loottable.LootableBlockInventory { // Paper - LootTable API

    /**
     * Gets the number of ticks which this block will remain in the crafting
     * state for.
     *
     * @return number of ticks remaining
     * @see org.bukkit.block.data.type.Crafter#isCrafting()
     */
    int getCraftingTicks();

    /**
     * Sets the number of ticks which this block will remain in the crafting
     * state for.
     *
     * @param ticks number of ticks remaining
     * @see org.bukkit.block.data.type.Crafter#isCrafting()
     */
    void setCraftingTicks(int ticks);

    /**
     * Gets whether the slot at the specified index is disabled and will not
     * have items placed in it.
     *
     * @param slot slot index
     * @return whether the slot is disabled
     */
    boolean isSlotDisabled(int slot);

    /**
     * Sets whether the slot at the specified index is disabled and will not
     * have items placed in it.
     *
     * @param slot slot index
     * @param disabled whether the slot should be disabled
     */
    void setSlotDisabled(int slot, boolean disabled);

    /**
     * Gets whether this Crafter is powered.
     *
     * @return powered status
     */
    boolean isTriggered();

    /**
     * Sets whether this Crafter is powered.
     *
     * @param triggered powered status
     */
    void setTriggered(boolean triggered);
Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java (Java)

Code before:
         */
        WALK_UNDERWATER,
        /**
         * Player moves on the surface of water one centimeter
         */
        WALK_ON_WATER,
        /**
         * Player sprints one centimeter
         */
        SPRINT,
        /**
         * Player crouches one centimeter (does not effect exhaustion, but fires
         * nonetheless)
         */
        CROUCH,
        /**
         * Player walks one centimeter (does not effect exhaustion, but fires
         * nonetheless)
         */
        WALK,
        /**
         * Player regenerated health
         */
        REGEN,
        /**
         * Player was affected by an enchantment
         */
        ENCHANTMENT_EFFECT,
        /**
         * Unknown exhaustion reason
         */
        UNKNOWN
    }

    @NotNull
    @Override
    public HandlerList getHandlers() {
        return HANDLER_LIST;
    }

    @NotNull
    public static HandlerList getHandlerList() {
        return HANDLER_LIST;
    }
}


Review comment (suggestion):
it isn't yet on the wiki so the link below isn't real but when the wiki gets updated, it would probably be good for the description to be more specific like this:
```md
Player was affected by <a href="https://minecraft.wiki/w/Enchantment_definition#apply_exhaustion">minecraft:apply_exhaustion</a> enchantment effect component.
```


Code after:
         */
        WALK_UNDERWATER,
        /**
         * Player moves on the surface of water one centimeter
         */
        WALK_ON_WATER,
        /**
         * Player sprints one centimeter
         */
        SPRINT,
        /**
         * Player crouches one centimeter (does not effect exhaustion, but fires
         * nonetheless)
         */
        CROUCH,
        /**
         * Player walks one centimeter (does not effect exhaustion, but fires
         * nonetheless)
         */
        WALK,
        /**
         * Player regenerated health
         */
        REGEN,
        /**
         * Player was affected by an enchantment
         * @see <a href="https://minecraft.wiki/w/Enchantment_definition#apply_exhaustion">Minecraft Wiki: Enchantment Effects "apply_exhaustion"</a>
         */
        // TODO - snapshot - In release check if this Wiki URL exists
        ENCHANTMENT_EFFECT,
        /**
         * Unknown exhaustion reason
         */
        UNKNOWN
    }

    @NotNull
    @Override
    public HandlerList getHandlers() {
        return HANDLER_LIST;
    }

    @NotNull
    public static HandlerList getHandlerList() {
        return HANDLER_LIST;
    }
}
Repository: PatilShreyas/Foodium
File: app/src/main/java/dev/shreyaspatil/foodium/ui/details/PostDetailsActivity.kt (Kotlin)

Code before:
    }

    override fun getViewBinding(): ActivityPostDetailsBinding =
        ActivityPostDetailsBinding.inflate(layoutInflater)

    override fun getViewModel() = viewModelOf<PostDetailsViewModel>(mViewModelProvider)

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when (item.itemId) {
            android.R.id.home -> {
                supportFinishAfterTransition()
                return true
            }

            R.id.action_share -> {
                if (getPost != null) {
                    val post = getPost!!
                    val shareMsg = """
                        "${post.title}" by ${post.author} on Foodium App
                    """.trimIndent()

                    val intent = Intent()
                    intent.action = Intent.ACTION_SEND
                    intent.putExtra(Intent.EXTRA_TEXT, shareMsg)
                    intent.type = "text/plain"
                    startActivity(Intent.createChooser(intent, "Share to:"))
                }
                return true
            }
        }

        return super.onOptionsItemSelected(item)
    }
}


Review comment (suggestion):
You can use `ShareCompat` class which is recommended by Android officials for such use case. Here's the reference: https://medium.com/androiddevelopers/sharing-content-between-android-apps-2e6db9d1368b

Code after:

    override fun getViewModel() = viewModelOf<PostDetailsViewModel>(mViewModelProvider)

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when (item.itemId) {
            android.R.id.home -> {
                supportFinishAfterTransition()
                return true
            }

            R.id.action_share -> {
                val shareMsg = """
                    "${post.title}" by ${post.author} on Foodium App
                """.trimIndent()

                val intent = ShareCompat.IntentBuilder.from(this)
                    .setType("text/plain")
                    .setText(shareMsg)
                    .intent

                if (intent.resolveActivity(packageManager) != null) {
                    startActivity(intent)
                }
                return true
            }
        }

        return super.onOptionsItemSelected(item)
    }

    companion object {
        const val POST_ID = "postId"
    }
}