<commit_before>/*
 * Copyright (c) 2015-2017, <NAME> <antoniogmc at gmail dot com>
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.resp.protocol;

import static com.github.tonivade.resp.protocol.SafeString.safeString;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;
import static tonivade.equalizer.Equalizer.equalizer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

public abstract class RedisToken {

  private static final String SEPARATOR = "=>";

  private final RedisTokenType type;

  private final Object value;

  private RedisToken(RedisTokenType type, Object value) {
    this.type = requireNonNull(type);
    this.value = value;
  }

  public RedisTokenType getType() {
    return type;
  }

  @SuppressWarnings("unchecked")
  public <T> T getValue() {
    return (T) value;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(value);
  }

  @Override
  public boolean equals(Object obj) {
    return equalizer(this).append((one, other) -> Objects.equals(one.value, other.value)).applyTo(obj);
  }

  @Override
  public String toString() {
    return type + SEPARATOR + value;
  }

  public static RedisToken string(SafeString str) {
    return new StringRedisToken(str);
  }

  public static RedisToken string(String str) {
    return new StringRedisToken(safeString(str));
  }

  public static RedisToken status(String str) {
    return new StatusRedisToken(safeString(str));
  }

  public static RedisToken integer(boolean b) {
    return new IntegerRedisToken(b ? 1 : 0);
  }

  public static RedisToken integer(int i) {
    return new IntegerRedisToken(i);
  }

  public static RedisToken error(String str) {
    return new ErrorRedisToken(safeString(str));
  }

  public static RedisToken array(RedisToken... redisTokens) {
    return new ArrayRedisToken(asList(redisTokens));<commit_msg>added new method to create null strings<commit_after>/*
 * Copyright (c) 2015-2017, <NAME> <antoniogmc at gmail dot com>
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.resp.protocol;

import static com.github.tonivade.resp.protocol.SafeString.safeString;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;
import static tonivade.equalizer.Equalizer.equalizer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

public abstract class RedisToken {

  private static final String SEPARATOR = "=>";

  private final RedisTokenType type;

  private final Object value;

  private RedisToken(RedisTokenType type, Object value) {
    this.type = requireNonNull(type);
    this.value = value;
  }

  public RedisTokenType getType() {
    return type;
  }

  @SuppressWarnings("unchecked")
  public <T> T getValue() {
    return (T) value;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(value);
  }

  @Override
  public boolean equals(Object obj) {
    return equalizer(this).append((one, other) -> Objects.equals(one.value, other.value)).applyTo(obj);
  }

  @Override
  public String toString() {
    return type + SEPARATOR + value;
  }

  public static RedisToken nullString() {
    return new StringRedisToken(null);
  }

  public static RedisToken string(SafeString str) {
    return new StringRedisToken(str);
  }

  public static RedisToken string(String str) {
    return new StringRedisToken(safeString(str));
  }

  public static RedisToken status(String str) {
    return new StatusRedisToken(safeString(str));
  }

  public static RedisToken integer(boolean b) {
    return new IntegerRedisToken(b ? 1 : 0);
  }

  public static RedisToken integer(int i) {
    return new IntegerRedisToken(i);
  }

  public static RedisToken error(String str) {
    return new ErrorRedisToken(safeString(str));
  }

  public static RedisToken array(RedisToken... redisTokens) {
    return new ArrayRedisToken(asList(redisTokens));
{'fraction_non_alphanumeric': 0.09884001933301112, 'fraction_numerical': 0.004833252779120348, 'mean_word_length': 4.16729088639201, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2495956', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1257, 'n_words': 340}