diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index e80b5e3..013203f
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -229,7 +229,7 @@ function book_node_load($nodes) {
  */
 function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
   if ($view_mode == 'full') {
-    if (!empty($node->book['bid']) && empty($node->in_preview)) {
+    if (!empty($node->book['bid']) && !$node->isInPreview()) {
       $book_node = Node::load($node->book['bid']);
       if (!$book_node->access()) {
         return;
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index f7374da..48e9a1f
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -589,7 +589,7 @@ function template_preprocess_node(&$variables) {
   // The 'page' variable is set to TRUE in two occasions:
   //   - The view mode is 'full' and we are on the 'node.view' route.
   //   - The node is in preview and view mode is either 'full' or 'default'.
-  $variables['page'] = ($variables['view_mode'] == 'full' && (node_is_page($node)) || (isset($node->in_preview) && in_array($node->preview_view_mode, array('full', 'default'))));
+  $variables['page'] = ($variables['view_mode'] == 'full' && (node_is_page($node)) || ($node->isInPreview() && in_array($node->preview_view_mode, array('full', 'default'))));

   // Helpful $content variable for templates.
   $variables += array('content' => array());
diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php
index afa31e3..d555022
--- a/core/modules/node/src/Entity/Node.php
+++ b/core/modules/node/src/Entity/Node.php
@@ -79,7 +79,7 @@ class Node extends ContentEntityBase implements NodeInterface {
    *
    * @var true|null
    */
-  public $in_preview = NULL;
+  protected $in_preview = NULL;

   /**
    * {@inheritdoc}
@@ -341,6 +341,21 @@ public function setRevisionAuthorId($uid) {
   /**
    * {@inheritdoc}
    */
+  public function isInPreview() {
+   return $this->in_preview;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setInPreview($in_preview) {
+    $this->in_preview = (bool) $in_preview;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
     $fields['nid'] = BaseFieldDefinition::create('integer')
       ->setLabel(t('Node ID'))
diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php
index c584660..3aceea9
--- a/core/modules/node/src/NodeForm.php
+++ b/core/modules/node/src/NodeForm.php
@@ -88,7 +88,7 @@ public function form(array $form, FormStateInterface $form_state) {
       // Rebuild the form.
       $form_state->setRebuild();
       $this->entity = $preview->getFormObject()->getEntity();
-      unset($this->entity->in_preview);
+      $this->entity->setInPreview(FALSE);

       // Remove the stale temp store entry for existing nodes.
       if (!$this->entity->isNew()) {
@@ -343,7 +343,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
    */
   public function preview(array $form, FormStateInterface $form_state) {
     $store = $this->tempStoreFactory->get('node_preview');
-    $this->entity->in_preview = TRUE;
+    $this->entity->setInPreview(TRUE);
     $store->set($this->entity->uuid(), $form_state);
     $form_state->setRedirect('entity.node.preview', array(
       'node_preview' => $this->entity->uuid(),
diff --git a/core/modules/node/src/NodeInterface.php b/core/modules/node/src/NodeInterface.php
index 9610a99..1e81a92
--- a/core/modules/node/src/NodeInterface.php
+++ b/core/modules/node/src/NodeInterface.php
@@ -168,4 +168,22 @@ public function setRevisionAuthorId($uid);
    */
   public function prepareLangcode();

+  /**
+   * Checks if the node is in preview mode.
+   *
+   * @return bool
+   *   TRUE if the node is in preview mode.
+   */
+  public function isInPreview();
+
+  /**
+   * Set if the node in to be viewed in preview mode.
+   *
+   * @param bool $in_preview
+   *   Boolean value to indicate if the node in to be viewed in preview mode.
+   *
+   * @return $this
+   */
+  public function setInPreview($in_preview);
+
 }
diff --git a/core/modules/node/src/NodeViewBuilder.php b/core/modules/node/src/NodeViewBuilder.php
index 37db17d..06a909b
--- a/core/modules/node/src/NodeViewBuilder.php
+++ b/core/modules/node/src/NodeViewBuilder.php
@@ -39,7 +39,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
             $entity->id(),
             $view_mode,
             $langcode,
-            !empty($entity->in_preview),
+            $entity->isInPreview(),
           ]],
           '#create_placeholder' => TRUE,
         );
@@ -65,7 +65,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
     $defaults = parent::getBuildDefaults($entity, $view_mode, $langcode);

     // Don't cache nodes that are in 'preview' mode.
-    if (isset($defaults['#cache']) && isset($entity->in_preview)) {
+    if (isset($defaults['#cache']) && $entity->isInPreview()) {
       unset($defaults['#cache']);
     }

diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 9b3be36..3339b77
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -38,7 +38,7 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
  * Implements hook_ENTITY_TYPE_view() for node entities.
  */
 function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
-  if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
+  if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && !$node->isInPreview()) {
     $build['statistics_content_counter']['#attached']['library'][] = 'statistics/drupal.statistics';
     $settings = array('data' => array('nid' => $node->id()), 'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')->toString());
     $build['statistics_content_counter']['#attached']['drupalSettings']['statistics'] = $settings;
