<commit_before>/*
 * Copyright 2013 <NAME>
 * 
 * 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 org.pitest.mutationtest.engine;

import org.pitest.classinfo.ClassName;
import org.pitest.mutationtest.MethodName;

/**
 * The co-ordinates of a method within a class.
 * 
 */
public class Location {

  private final ClassName  clazz;
  private final MethodName method;
  private final String     methodDesc;

  public Location(final ClassName clazz, final MethodName method,
      final String methodDesc) {
    this.clazz = clazz;
    this.method = method;
    this.methodDesc = methodDesc;
  }

  public static Location location(final ClassName clazz,
      final MethodName method, final String methodDesc) {
    return new Location(clazz, method, methodDesc);
  }

  public ClassName getClassName() {
    return this.clazz;
  }

  public MethodName getMethodName() {
    return this.method;
  }

  public String getMethodDesc() {
    return this.methodDesc;
  }
  
  public Location with(ClassName clazz) {
    return new Location(clazz,this.method, this.methodDesc);
  }
    
  public Location withMethod(String method) {
    return new Location(clazz, MethodName.fromString(method), this.methodDesc);
  }
  
  public Location withClass(String clazz) {
    return new Location(ClassName.fromString(clazz),this.method, this.methodDesc);
  }
  
  public Location withMethodDesc(String desc) {
    return new Location(clazz, method, desc);
  }
  
  
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = (prime * result)
        + ((this.clazz == null) ? 0 : this.clazz.hashCode());
    result = (prime * result)
        + ((this.method == null) ? 0 : this.method.hashCode());
    result = (prime * result)
        + ((this.methodDesc == null) ? 0 : this.methodDesc.hashCode());
    return result;
  }

  @Override
  public boolean equals(final Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Location other = (Location) obj;
    if (this.clazz == null) {
      if (other.clazz != null) {
        return false;
      }
    } else if (!this.clazz.equals(other.clazz)) {
      return false;
    }
    if (this.method == null) {
      if (other.method != null) {
        return false;
      }
    } else if (!this.method.equals(other.method)) {
      return false;
    }
    if (this.methodDesc == null) {
      if (other.methodDesc != null) {
        return false;
      }
    } else if (!this.methodDesc.equals(other.methodDesc)) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "Location [clazz=" + this.clazz + ", method=" + this.method
        + ", methodDesc=" + this.methodDesc + "]";
  }

  public String describe() {
    return method.name();
  }

}
<commit_msg>allow subclasses to return specialised types<commit_after>/*
 * Copyright 2013 <NAME>
 * 
 * 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 org.pitest.mutationtest.engine;

import org.pitest.classinfo.ClassName;
import org.pitest.mutationtest.MethodName;

/**
 * The co-ordinates of a method within a class.
 * 
 */
public class Location {

  private final ClassName  clazz;
  private final MethodName method;
  private final String     methodDesc;

  public Location(final ClassName clazz, final MethodName method,
      final String methodDesc) {
    this.clazz = clazz;
    this.method = method;
    this.methodDesc = methodDesc;
  }

  public static Location location(final ClassName clazz,
      final MethodName method, final String methodDesc) {
    return new Location(clazz, method, methodDesc);
  }
  
  public ClassName getClassName() {
    return this.clazz;
  }

  public MethodName getMethodName() {
    return this.method;
  }

  public String getMethodDesc() {
    return this.methodDesc;
  }
  
  public Location with(ClassName clazz) {
    return newLocation(clazz,this.method, this.methodDesc);
  }
    
  public Location withMethod(String method) {
    return newLocation(clazz, MethodName.fromString(method), this.methodDesc);
  }
  
  public Location withClass(String clazz) {
    return newLocation(ClassName.fromString(clazz),this.method, this.methodDesc);
  }
  
  public Location withMethodDesc(String desc) {
    return newLocation(clazz, method, desc);
  }
  
  protected Location newLocation(final ClassName clazz,
      final MethodName method, final String methodDesc) {
    return new Location(clazz, method, methodDesc);
  }
  
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = (prime * result)
        + ((this.clazz == null) ? 0 : this.clazz.hashCode());
    result = (prime * result)
        + ((this.method == null) ? 0 : this.method.hashCode());
    result = (prime * result)
        + ((this.methodDesc == null) ? 0 : this.methodDesc.hashCode());
    return result;
  }

  @Override
  public boolean equals(final Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Location other = (Location) obj;
    if (this.clazz == null) {
      if (other.clazz != null) {
        return false;
      }
    } else if (!this.clazz.equals(other.clazz)) {
      return false;
    }
    if (this.method == null) {
      if (other.method != null) {
        return false;
      }
    } else if (!this.method.equals(other.method)) {
      return false;
    }
    if (this.methodDesc == null) {
      if (other.methodDesc != null) {
        return false;
      }
    } else if (!this.methodDesc.equals(other.methodDesc)) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "Location [clazz=" + this.clazz + ", method=" + this.method
        + ", methodDesc=" + this.methodDesc + "]";
  }

  public String describe() {
    return method.name();
  }

}

{'fraction_non_alphanumeric': 0.10972320794889993, 'fraction_numerical': 0.00397444996451384, 'mean_word_length': 2.8210412147505424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4669812', 'n_tokens_mistral': 2122, 'n_tokens_neox': 2064, 'n_words': 639}