<commit_before>package com.gauravbytes.java8.methodref;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;

/**
 * 
 * @author <NAME>
 *
 */
public class MethodReferenceExample {
	static class Job {
		private String jobName;

		public Job (String jobName) {
			this.jobName = jobName;
		}
		
		@Override
		public String toString() {
			return "[job: " + jobName + "]";
		}
	}
	
	static class Employee {
		private String firstName;
		private String lastName;
		private int age;
		
		Employee(String firstName, String lastName, int age) {
			this.firstName = firstName;
			this.lastName = lastName;
		}
		
		
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + age;
			result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
			result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Employee other = (Employee) obj;
			if (age != other.age)
				return false;
			if (firstName == null) {
				if (other.firstName != null)
					return false;
			} else if (!firstName.equals(other.firstName))
				return false;
			if (lastName == null) {
				if (other.lastName != null)
					return false;
			} else if (!lastName.equals(other.lastName))
				return false;
			return true;
		}

		@Override
		public String toString() {
			return "Employee [firstName=" + firstName + ", lastName=" + lastName + ", age=" + age + "]";
		}
	}
	
	public static int compareByAge(Employee first, Employee second) {
		return Integer.compare(first.age, second.age);
	}
	public static void main(String[] args) {
		instanceMethodReference();
		staticMethodReference();
		constructorReference();
		
	}
	
	private static void staticMethodReference() {
		Comparator<Employee> ageComparator = MethodReferenceExample::compareByAge;

		//above is equivalent to below one
		//Comparator<Employee> ageComparator2 = (first, second) -> MethodReferenceExample.compareByAge(first, second);
		List<Employee> employees = Arrays.asList(new Employee("Gaurav", "Mazra", 27), new Employee("Mohan", "Sharma", 29), new Employee("Gurpreet", "Singh", 24));
		System.out.println(employees);
		
		Collections.sort(employees, ageComparator);
		System.out.println(employees);
		
	}
	
	private static void constructorReference() {
		Function<String, Job> jobCreator = Job::new;
		// this is equivalent to 
		//Function<String, Job> jobCreator2 = (jobName) -> new Job(jobName);
		
		System.out.println(jobCreator.apply("Create a new task"));
	}

	private static void instanceMethodReference() {
		Comparator<String> stringIgnoreCase = String::compareToIgnoreCase;
		// this is equivalent to below
		//Comparator<String> stringIgnoreCase2 = (first, second) -> first.compareToIgnoreCase(second);
		List<String> values = Arrays.asList("Gaurav", "Sunil", "Anil", "Rajesh", "sajjad");
		System.out.println(values);
		
		
		Collections.sort(values, stringIgnoreCase);
		System.out.println(values);
	}
}
<commit_msg>some sysouts<commit_after>package com.gauravbytes.java8.methodref;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;

/**
 * 
 * @author <NAME>
 *
 */
public class MethodReferenceExample {
	static class Job {
		private String jobName;

		public Job (String jobName) {
			this.jobName = jobName;
		}
		
		@Override
		public String toString() {
			return "[job: " + jobName + "]";
		}
	}
	
	static class Employee {
		private String firstName;
		private String lastName;
		private int age;
		
		Employee(String firstName, String lastName, int age) {
			this.firstName = firstName;
			this.lastName = lastName;
		}
		
		
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + age;
			result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
			result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Employee other = (Employee) obj;
			if (age != other.age)
				return false;
			if (firstName == null) {
				if (other.firstName != null)
					return false;
			} else if (!firstName.equals(other.firstName))
				return false;
			if (lastName == null) {
				if (other.lastName != null)
					return false;
			} else if (!lastName.equals(other.lastName))
				return false;
			return true;
		}

		@Override
		public String toString() {
			return "Employee [firstName=" + firstName + ", lastName=" + lastName + ", age=" + age + "]";
		}
	}
	
	public static int compareByAge(Employee first, Employee second) {
		return Integer.compare(first.age, second.age);
	}
	public static void main(String[] args) {
		instanceMethodReference();
		staticMethodReference();
		constructorReference();
	}
	
	private static void staticMethodReference() {
		System.out.println("static method reference");
		Comparator<Employee> ageComparator = MethodReferenceExample::compareByAge;

		//above is equivalent to below one
		//Comparator<Employee> ageComparator2 = (first, second) -> MethodReferenceExample.compareByAge(first, second);
		List<Employee> employees = Arrays.asList(new Employee("Gaurav", "Mazra", 27), new Employee("Mohan", "Sharma", 29), new Employee("Gurpreet", "Singh", 24));
		System.out.println(employees);
		
		Collections.sort(employees, ageComparator);
		System.out.println(employees);
	}
	
	private static void constructorReference() {
		System.out.println("Constructor reference");
		Function<String, Job> jobCreator = Job::new;
		// this is equivalent to 
		//Function<String, Job> jobCreator2 = (jobName) -> new Job(jobName);
		
		System.out.println(jobCreator.apply("Create a new task"));
	}

	private static void instanceMethodReference() {
		System.out.println("Instance method reference");
		Comparator<String> stringIgnoreCase = String::compareToIgnoreCase;
		// this is equivalent to below
		//Comparator<String> stringIgnoreCase2 = (first, second) -> first.compareToIgnoreCase(second);
		List<String> values = Arrays.asList("Gaurav", "Sunil", "Anil", "Rajesh", "sajjad");
		System.out.println(values);
		
		Collections.sort(values, stringIgnoreCase);
		System.out.println(values);
	}
}

{'fraction_non_alphanumeric': 0.1269124289669241, 'fraction_numerical': 0.004371266210112196, 'mean_word_length': 3.287320424734541, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '4158016', 'n_tokens_mistral': 2435, 'n_tokens_neox': 2063, 'n_words': 535}