Skip to content

Instantly share code, notes, and snippets.

View eliseevdry's full-sized avatar
💭
Learning Java

eliseevdry eliseevdry

💭
Learning Java
View GitHub Profile
@eliseevdry
eliseevdry / FieldsComparingUtils.java
Created September 4, 2022 15:55
Util class for comparing Object by same fields
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.*;
import java.util.stream.Collectors;
public class FieldsComparingUtils {
public static boolean equalsForSameFields(Object o1, Object o2, String... exceptFieldNames) throws IllegalAccessException {
Class<?> o1Class = o1.getClass();
Class<?> o2Class = o2.getClass();