<commit_before>/*
 * Copyright (c) 2015 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
 *
 * 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 com.google.common.truth.extension;

import static com.google.common.truth.Truth.assertAbout;

import com.google.common.truth.FailureStrategy;
import com.google.common.truth.Subject;
import com.google.common.truth.SubjectFactory;

/**
 * A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
 *
 * @author <NAME> (<EMAIL>)
 */
public final class EmployeeSubject extends Subject<EmployeeSubject, Employee> {

  // User-defined entry point
  public static EmployeeSubject assertThat(Employee employee) {
    return assertAbout(EMPLOYEE_SUBJECT_FACTORY).that(employee);
  }

  // Static method for getting the subject factory (for use with assertAbout())
  public static SubjectFactory<EmployeeSubject, Employee> employee() {
    return EMPLOYEE_SUBJECT_FACTORY;
  }

  // Boiler-plate SubjectFactory for EmployeeSubject
  private static final SubjectFactory<EmployeeSubject, Employee> EMPLOYEE_SUBJECT_FACTORY =
      new SubjectFactory<EmployeeSubject, Employee>() {
        @Override
        public EmployeeSubject getSubject(FailureStrategy failureStrategy, Employee target) {
          return new EmployeeSubject(failureStrategy, target);
        }
      };

  private EmployeeSubject(FailureStrategy failureStrategy, Employee subject) {
    super(failureStrategy, subject);
  }

  // User-defined test assertion SPI below this point

  public void hasName(String name) {
    if (!getSubject().name().equals(name)) {
      fail("has name", name);
    }
  }

  public void hasUsername(String username) {
    if (!getSubject().username().equals(username)) {
      fail("has username", username);
    }
  }

  public void hasId(long id) {
    if (getSubject().id() != id) {
      fail("has id", id);
    }
  }

  public void hasLocation(Employee.Location location) {
    if (getSubject().location() != location) {
      fail("has location", location);
    }
  }
<commit_msg>Add missing @Nullable annotations to Truth docs. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=96236748<commit_after>/*
 * Copyright (c) 2015 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
 *
 * 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 com.google.common.truth.extension;

import static com.google.common.truth.Truth.assertAbout;

import com.google.common.truth.FailureStrategy;
import com.google.common.truth.Subject;
import com.google.common.truth.SubjectFactory;

import javax.annotation.Nullable;

/**
 * A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
 *
 * @author <NAME> (<EMAIL>)
 */
public final class EmployeeSubject extends Subject<EmployeeSubject, Employee> {

  // User-defined entry point
  public static EmployeeSubject assertThat(@Nullable Employee employee) {
    return assertAbout(EMPLOYEE_SUBJECT_FACTORY).that(employee);
  }

  // Static method for getting the subject factory (for use with assertAbout())
  public static SubjectFactory<EmployeeSubject, Employee> employee() {
    return EMPLOYEE_SUBJECT_FACTORY;
  }

  // Boiler-plate SubjectFactory for EmployeeSubject
  private static final SubjectFactory<EmployeeSubject, Employee> EMPLOYEE_SUBJECT_FACTORY =
      new SubjectFactory<EmployeeSubject, Employee>() {
        @Override
        public EmployeeSubject getSubject(
            FailureStrategy failureStrategy, @Nullable Employee target) {
          return new EmployeeSubject(failureStrategy, target);
        }
      };

  private EmployeeSubject(FailureStrategy failureStrategy, @Nullable Employee subject) {
    super(failureStrategy, subject);
  }

  // User-defined test assertion SPI below this point

  public void hasName(String name) {
    if (!getSubject().name().equals(name)) {
      fail("has name", name);
    }
  }

  public void hasUsername(String username) {
    if (!getSubject().username().equals(username)) {
      fail("has username", username);
    }
  }

  public void hasId(long id) {
    if (getSubject().id() != id) {
      fail("has id", id);
    }
  }

  public void hasLocation(Employee.Location location) {
    if (getSubject().location() != location) {
      fail("has location", location);
    }
  }

{'fraction_non_alphanumeric': 0.10653706880121974, 'fraction_numerical': 0.004574042309891366, 'mean_word_length': 3.8368663594470047, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '3635324', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1390, 'n_words': 449}