<commit_before>package nl.mvdr.tinustris.gui;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import javafx.scene.Group;
import javafx.scene.Node;
import nl.mvdr.tinustris.model.OnePlayerGameState;
import nl.mvdr.tinustris.model.Orientation;
import nl.mvdr.tinustris.model.Point;
import nl.mvdr.tinustris.model.Tetromino;

/**
 * Shows the upcoming block.
 * 
 * @author <NAME>
 */
class NextBlockRenderer extends BlockGroupRenderer {
    /** Previous value for the next tetromino field, currently being displayed. Initially null. */
    private Tetromino previousValue = null;
    
    /**
     * Constructor.
     * 
     * @param blockCreator creator
     */
    NextBlockRenderer(BlockCreator blockCreator) {
        super(blockCreator);
    }
    
    /** {@inheritDoc} */
    @Override
    public void render(OnePlayerGameState gameState) {
        super.render(gameState);
        previousValue = gameState.getNext();
    }
    
    /** {@inheritDoc} */
    @Override
    List<Optional<Group>> createGroups(OnePlayerGameState gameState) {
        Optional<Group> group;
        
        Tetromino nextBlock = gameState.getNext();
        if (previousValue == nextBlock) {
            // Active block location is unchanged; no need to update.
            group = Optional.empty();
        } else {
            // This is the first frame, or the active block's location has changed.
            // Render the group.
            group = Optional.of(new Group());
            for (Point point : nextBlock.getPoints(Orientation.getDefault())) {
                // for aesthetics, center the tetromino
                if (nextBlock != Tetromino.O) {
                    point = point.translate(0, -1);<commit_msg>Using an Optional for the previous value.<commit_after>package nl.mvdr.tinustris.gui;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import javafx.scene.Group;
import javafx.scene.Node;
import nl.mvdr.tinustris.model.OnePlayerGameState;
import nl.mvdr.tinustris.model.Orientation;
import nl.mvdr.tinustris.model.Point;
import nl.mvdr.tinustris.model.Tetromino;

/**
 * Shows the upcoming block.
 * 
 * @author <NAME>
 */
class NextBlockRenderer extends BlockGroupRenderer {
    /** Previous value for the next tetromino field, currently being displayed. Initially empty. */
    private Optional<Tetromino> previousValue;
    
    /**
     * Constructor.
     * 
     * @param blockCreator creator
     */
    NextBlockRenderer(BlockCreator blockCreator) {
        super(blockCreator);
        previousValue = Optional.empty();
    }
    
    /** {@inheritDoc} */
    @Override
    public void render(OnePlayerGameState gameState) {
        super.render(gameState);
        previousValue = Optional.of(gameState.getNext());
    }
    
    /** {@inheritDoc} */
    @Override
    List<Optional<Group>> createGroups(OnePlayerGameState gameState) {
        Optional<Group> group;
        
        Tetromino nextBlock = gameState.getNext();
        if (previousValue.filter(t -> t == nextBlock).isPresent()) {
            // Active block location is unchanged; no need to update.
            group = Optional.empty();
        } else {
            // This is the first frame, or the active block's location has changed.
            // Render the group.
            group = Optional.of(new Group());
            for (Point point : nextBlock.getPoints(Orientation.getDefault())) {
                // for aesthetics, center the tetromino
                if (nextBlock != Tetromino.O) {
                    point = point.translate(0, -1);
{'fraction_non_alphanumeric': 0.1074792243767313, 'fraction_numerical': 0.00110803324099723, 'mean_word_length': 2.499031007751938, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2405306', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1012, 'n_words': 247}