<commit_before>package com.celements.model.util;

import java.util.Objects;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.model.reference.SpaceReference;

import com.celements.web.service.IWebUtilsService;
import com.google.common.base.Strings;
import com.xpn.xwiki.web.Utils;

public class XObjectField<T> {

  private final DocumentReference classRef;
  private final String name;

  private final Class<T> token;

  public XObjectField(@NotNull DocumentReference classRef, @NotNull String name, Class<T> token) {
    this.classRef = Objects.requireNonNull(classRef);
    this.name = Objects.requireNonNull(Strings.emptyToNull(name));
    this.token = Objects.requireNonNull(token);
  }

  public XObjectField(@Nullable String wiki, @NotNull String classSpace, @NotNull String className,
      @NotNull String name, Class<T> token) {
    this(new DocumentReference(Objects.requireNonNull(Strings.emptyToNull(className)),
        new SpaceReference(Objects.requireNonNull(Strings.emptyToNull(classSpace)), getWebUtils()
            .resolveWikiReference(wiki))), name, token);
  }

  public XObjectField(@NotNull String classSpace, @NotNull String className, @NotNull String name,
      Class<T> token) {
    this(null, classSpace, className, name, token);
  }

  public DocumentReference getClassRef() {
    return new DocumentReference(classRef);
  }

  public String getName() {
    return name;
  }

  public Class<T> getToken() {
    return token;
  }

  @Override
  public int hashCode() {
    return new HashCodeBuilder().append(getClassRef()).append(getName()).hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof XObjectField) {
      XObjectField<?> other = (XObjectField<?>) obj;
      return new EqualsBuilder().append(this.getClassRef(), other.getClassRef()).append(this
          .getName(), other.getName()).isEquals();
    }
    return false;
  }

  @Override
  public String toString() {
    return Utils.getComponent(IWebUtilsService.class).serializeRef(getClassRef(), true) + "."
        + getName();
  }

  private static IWebUtilsService getWebUtils() {
    return Utils.getComponent(IWebUtilsService.class);
  }

}<commit_msg>added XObjectField.toString(boolean)<commit_after>package com.celements.model.util;

import java.util.Objects;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.model.reference.SpaceReference;

import com.celements.web.service.IWebUtilsService;
import com.google.common.base.Strings;
import com.xpn.xwiki.web.Utils;

public class XObjectField<T> {

  private final DocumentReference classRef;
  private final String name;

  private final Class<T> token;

  public XObjectField(@NotNull DocumentReference classRef, @NotNull String name, Class<T> token) {
    this.classRef = Objects.requireNonNull(classRef);
    this.name = Objects.requireNonNull(Strings.emptyToNull(name));
    this.token = Objects.requireNonNull(token);
  }

  public XObjectField(@Nullable String wiki, @NotNull String classSpace, @NotNull String className,
      @NotNull String name, Class<T> token) {
    this(new DocumentReference(Objects.requireNonNull(Strings.emptyToNull(className)),
        new SpaceReference(Objects.requireNonNull(Strings.emptyToNull(classSpace)), getWebUtils()
            .resolveWikiReference(wiki))), name, token);
  }

  public XObjectField(@NotNull String classSpace, @NotNull String className, @NotNull String name,
      Class<T> token) {
    this(null, classSpace, className, name, token);
  }

  public DocumentReference getClassRef() {
    return new DocumentReference(classRef);
  }

  public String getName() {
    return name;
  }

  public Class<T> getToken() {
    return token;
  }

  @Override
  public int hashCode() {
    return new HashCodeBuilder().append(getClassRef()).append(getName()).hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof XObjectField) {
      XObjectField<?> other = (XObjectField<?>) obj;
      return new EqualsBuilder().append(getClassRef(), other.getClassRef()).append(getName(), other
          .getName()).isEquals();
    }
    return false;
  }

  @Override
  public String toString() {
    return toString(true);
  }

  public String toString(boolean local) {
    return getWebUtils().serializeRef(getClassRef(), local) + "." + getName();
  }

  private static IWebUtilsService getWebUtils() {
    return Utils.getComponent(IWebUtilsService.class);
  }

}
{'fraction_non_alphanumeric': 0.11379097093382808, 'fraction_numerical': 0.0, 'mean_word_length': 4.513636363636364, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '933429', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1377, 'n_words': 307}