<commit_before>/*
 * Cacheonix Systems licenses this file to You under the LGPL 2.1
 * (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *      http://www.cacheonix.org/products/cacheonix/license-lgpl-2.1.htm
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cacheonix.impl.cache.distributed.partitioned;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.cacheonix.impl.cache.item.Binary;
import org.cacheonix.impl.clock.Time;
import org.cacheonix.impl.net.serializer.SerializerUtils;
import org.cacheonix.impl.net.serializer.Wireable;
import org.cacheonix.impl.net.serializer.WireableBuilder;

/**
 * A value that can be cached, returned by read requests such as GetRequest.
 */
@SuppressWarnings("RedundantIfStatement")
public final class CacheableValue implements Wireable {

   /**
    * Builder used by WireableFactory.
    */
   public static final WireableBuilder BUILDER = new Builder();

   /**
    * A value.
    */
   private Binary binaryValue = null;

   /**
    * Expiration time. The value cannot be cache if the expiration time is null.
    */
   private Time timeToLeave = null;


   public CacheableValue() {

   }


   /**
    * Constructor.
    *
    * @param binaryValue a value.
    * @param timeToLeave expiration time. Set to null if the value cannot be cached.
    */
   public CacheableValue(final Binary binaryValue, final Time timeToLeave) {

      this.binaryValue = binaryValue;
      this.timeToLeave = timeToLeave;
   }


   /**
    * Returns the value.
    *
    * @return the value.
    */
   public Binary getBinaryValue() {

      return binaryValue;
   }


   /**
    * Returns the expiration time.
    *
    * @return the expiration time. Returns null if the value must not be cached.
    */
   public Time getTimeToLeave() {

      return timeToLeave;
   }


   /**
    * {@inheritDoc}
    */
   public void writeWire(final DataOutputStream out) throws IOException {

      SerializerUtils.writeBinary(out, binaryValue);
      SerializerUtils.writeTime(timeToLeave, out);
   }


   /**
    * {@inheritDoc}
    */
   public void readWire(final DataInputStream in) throws IOException, ClassNotFoundException {

      binaryValue = SerializerUtils.readBinary(in);
      timeToLeave = SerializerUtils.readTime(in);
   }


   /**
    * {@inheritDoc}
    */
   public int getWireableType() {

      return TYPE_CACHEABLE_VALUE;
   }


   /**
    * {@inheritDoc}
    */
   public boolean equals(final Object o) {

      if (this == o) {
         return true;
      }
      if (o == null || getClass() != o.getClass()) {
         return false;
      }<commit_msg>Code quality: added static imports.<commit_after>/*
 * Cacheonix Systems licenses this file to You under the LGPL 2.1
 * (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *      http://www.cacheonix.org/products/cacheonix/license-lgpl-2.1.htm
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cacheonix.impl.cache.distributed.partitioned;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.cacheonix.impl.cache.item.Binary;
import org.cacheonix.impl.clock.Time;
import org.cacheonix.impl.net.serializer.Wireable;
import org.cacheonix.impl.net.serializer.WireableBuilder;

import static org.cacheonix.impl.net.serializer.SerializerUtils.readBinary;
import static org.cacheonix.impl.net.serializer.SerializerUtils.readTime;
import static org.cacheonix.impl.net.serializer.SerializerUtils.writeBinary;
import static org.cacheonix.impl.net.serializer.SerializerUtils.writeTime;

/**
 * A value that can be cached, returned by read requests such as GetRequest.
 */
@SuppressWarnings("RedundantIfStatement")
public final class CacheableValue implements Wireable {

   /**
    * Builder used by WireableFactory.
    */
   public static final WireableBuilder BUILDER = new Builder();

   /**
    * A value.
    */
   private Binary binaryValue = null;

   /**
    * Expiration time. The value cannot be cache if the expiration time is null.
    */
   private Time timeToLeave = null;


   public CacheableValue() {

   }


   /**
    * Constructor.
    *
    * @param binaryValue a value.
    * @param timeToLeave expiration time. Set to null if the value cannot be cached.
    */
   public CacheableValue(final Binary binaryValue, final Time timeToLeave) {

      this.binaryValue = binaryValue;
      this.timeToLeave = timeToLeave;
   }


   /**
    * Returns the value.
    *
    * @return the value.
    */
   public Binary getBinaryValue() {

      return binaryValue;
   }


   /**
    * Returns the expiration time.
    *
    * @return the expiration time. Returns null if the value must not be cached.
    */
   public Time getTimeToLeave() {

      return timeToLeave;
   }


   /**
    * {@inheritDoc}
    */
   public void writeWire(final DataOutputStream out) throws IOException {

      writeBinary(out, binaryValue);
      writeTime(timeToLeave, out);
   }


   /**
    * {@inheritDoc}
    */
   public void readWire(final DataInputStream in) throws IOException, ClassNotFoundException {

      binaryValue = readBinary(in);
      timeToLeave = readTime(in);
   }


   /**
    * {@inheritDoc}
    */
   public int getWireableType() {

      return TYPE_CACHEABLE_VALUE;
   }


   /**
    * {@inheritDoc}
    */
   public boolean equals(final Object o) {

      if (this == o) {
         return true;
      }
      if (o == null || getClass() != o.getClass()) {
         return false;
      }
{'fraction_non_alphanumeric': 0.0964279993592824, 'fraction_numerical': 0.0012814352074323242, 'mean_word_length': 2.90738423028786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4628851', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1753, 'n_words': 554}