GithubHelp home page GithubHelp logo

java-util's People

Contributors

bowbahdoe avatar dependabot[bot] avatar dreddergun avatar jdereg avatar jremes-foss avatar jsnyder4 avatar kpartlow avatar lipisak avatar marcobjorge avatar osiris-team avatar sapradhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-util's Issues

Cannot use fastLookup hash using DeepHashCode

fastLookup.put(deepHashCode(entry.getKey()), entry);

Unfortunately, hashCodes are not intended to be unique, so it's possible that two keys would have the same hash and the second will overwrite the first. In a Map with 110 entries using unique 4 char Strings, I found 4 keys with duplicate hashes.

At that point what you're really after is a unique id for each Object (key). This would fix the above problem but I just realised there is a more fundamental problem with the idea of trying to compare Maps in general: There might be cases where you consider two keys in a map to be deeply equal, but Java does not consider them equal, hence it's possible to have them both in the same Map. At that point, you're conflicting with the principle of the same key in a Map always resolving to the same value. Maybe at that point you can compare the Set of values the equal keys map to but that's skirting on the edges of what a Map really is...

Question or Feature request: Compare complex objects

We try to use you GraphComparator to compare two complex objects each other.

For a simple object it is working really good, but I'm not able to get it work with properties which are an List of other Complex Objects which could contain again a complex object.

Let me explain better, if we have for Example this object (we will represent it for simplicity by an json object):

{
	"id": 1,
	"name": "Master1",
	"details": [{
		"id": 1,
		"name": "Master1.Detail1"
	}, {
		"id": 2,
		"name": "Master2.Detail2",
		"subDetail": [{
			"id1": 1,
			"name": "Master2.Detail2.SubDetail1"
		}]
	}]
}

In This Case if we change name in SubDetail1 and compare old with new object we need also to be notified that the property in the third level of 3 complex objects changed.

Is this possible with you library? Can we do a workaround to get it work?

GraphComparator could not find the new member of ArrayList

I am having a problem while using your great library as I want to compare two ArrayLists for differences using GraphComparator. I deleted an element of one of the lists and when I compared the old list and new list it shows that there is OBJECT_ORPHAN command. But when I reversed it by comparing the new list and the old list, it should show that there is a new object but somehow it could not detect.

My code is like this:

List<UnifiedBucket> ubs= new ArrayList<>(); // Assume I already put elements in the list 
List<UnifiedBucket> ubsCopy = cloner.deepClone(ubs);
ubsCopy.remove(25);
ubsCopy.get(14).setRawPolicy(null);
List<GraphComparator.Delta> deltas = GraphComparator.compare(ubs, ubsCopy, getIdFetcher()); //This works fine as I could find the OBJECT_ORPHAN

for (GraphComparator.Delta delta : deltas) {
	if (delta.getCmd() != GraphComparator.Delta.Command.LIST_SET_ELEMENT) {
		System.out.println(delta);
	}
}

List<GraphComparator.Delta> deltas2 = GraphComparator.compare(ubsCopy, ubs, getIdFetcher()); //This does not work fine as I could not find the new element that is not deleted in the ubs list

for (GraphComparator.Delta delta : deltas2) {
	if (delta.getCmd() != GraphComparator.Delta.Command.LIST_SET_ELEMENT) {
		System.out.println(delta);
	}
}

Any reason why?

Is java8 support removed?

Hi! For a not-so-legacy code i've to use java8, but if I try to use this library i receive this error:

java: cannot access com.cedarsoftware.util.GraphComparator
bad class file: /.m2/repository/com/cedarsoftware/java-util/2.0.0/java-util-2.0.0.jar!/com/cedarsoftware/util/GraphComparator.class
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

I must use an older version? GraphComparator has the same features?

Floating point values compared using ==

The following test fails

test() {
    Class1 x = new Class1(true, Math.tan(Math.PI / 4), 1);
    Class1 y = new Class1(true, 1.0, 1);
    assertTrue(DeepEquals.deepEquals(x, y));
}

class Class1 {
    private boolean b;
    private double d;
    int i;

    public Class1(boolean b, double d, int i) {
        super();
        this.b = b;
        this.d = d;
        this.i = i;
    }

}

`DeepEquals`: comparator of `SortedSet`s and `SortedMap`s is not considered, equality of ordered and unordered collections is inconsistent with JDK

The comparison of two SortedSets or SortedMaps with deepEquals does not work as expected, when the SortedSets or SortedMaps are not using the same comparator for ordering the elements. If not the same comparators are used, the method returns wrong results, as the iterators i1 and i2 used in compareOrderedCollection and compareSortedMap return elements in a different order.

With the default implementation of equals, this is not the case:

SortedMap<String, String> map1 = new TreeMap<>(Comparator.naturalOrder());
map1.put("a", "b");
map1.put("c", "d");
SortedMap<String, String> map2 = new TreeMap<>(Comparator.reverseOrder());
map2.put("a", "b");
map2.put("c", "d");
System.out.println(map1.equals(map2)); // true

In the JDK, the equals method of Sets and Maps does not consider the ordering in any case, even for SortedSets and SortedMaps. Instead SortedSets are considered to be equal to Sets (and respectively for Maps) when they contain exactly the same entries:

SortedSet<String> set1 = new TreeSet<>();
Set<String> set2 = new HashSet<>();
System.out.println(set1.equals(set2)); // true

Whereas deepEquals considers those two Sets to be not equal, because they are not both of the type SortedSets.

Problems when comparing unordered data structures

There seem to be some issues with DeepEquals in the handling of isContained within compareUnorderedCollection/compareUnorderedMap (i.e. colliding hashcode values):

a) Options (IGNORE_CUSTOM_EQUALS and ALLOW_STRINGS_TO_MATCH_NUMBERS) are not propagated.
b) When progagating options the Set of visited ItemsToCompare (or a copy if it) should be passed on to prevent StackOverFlow from occurring.

OSGi Support

Hello,

I'm trying to use your java-util in a OSGi environment and I found out that the library is not an OSGi bundle so I made some changes to make it a proper OSGi bundle and I'll submit a PR soon but I need some info:

  • I see that you have configured the Felix SCR plugin but I do not see any SCR code/descriptor
  • I see that you have set the DynamicImport-Package directive but I do not see any invocation of Class.forName or similar stuffs

Is there a reason for the two point above ?

GraphComparator: JSON path in fieldName

Option to use whole JSON path in the fieldName in GraphComparator.

This would be greatly appreciated, because when having the same field names as leafs in different document branches, it's not obvious which one is shown.

Different implementations of Lists/Sets/Maps are treated unequal

In some cases it might be nice if we can support this use case

public void testOrderedCollection() {
    List<String> a = Lists.newArrayList("one", "two", "three", "four",
            "five");
    List<String> b = Lists.newLinkedList(a);
    assertTrue(DeepEquals.deepEquals(a, b));
    }

Source files without license headers

Hi
The following source files are without license headers:

./src/main/java/com/cedarsoftware/util/ProxyFactory.java

./src/test/java/com/cedarsoftware/util/TestByteUtilities.java
./src/test/java/com/cedarsoftware/util/TestDateUtilities.java
./src/test/java/com/cedarsoftware/util/TestExceptionUtilities.java
./src/test/java/com/cedarsoftware/util/TestHandshakeException.java
./src/test/java/com/cedarsoftware/util/TestInetAddressUnknownHostException.java
./src/test/java/com/cedarsoftware/util/TestProxyFactory.java
./src/test/java/com/cedarsoftware/util/TestStringUtilities.java
./src/test/java/com/cedarsoftware/util/TestUrlInvocationHandlerWhenExceptionsAreThrown.java
./src/test/java/com/cedarsoftware/util/TestUrlInvocationHandlerWithPlainReader.java

Please, confirm the licensing of code and/or content/s, and add license headers.

https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Clarification

Thanks in advance
Regards

An illegal reflective access operation has occurred

Hello, we use com.cedarsoftware.util.GraphComparator to find differences between two objects. Running the code with java 11 we get a warning while access private static final field "serialVersionUID". I would expect that static final fields are skipped from comparison.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.cedarsoftware.util.ReflectionUtils (file:......../files-2.1/com.cedarsoftware/java-util/2.0.0/7cdce491c29122dc4a959a69f51064ef63eed31/java-util-2.0.0.jar) to field java.util.UUID.serialVersionUID
WARNING: Please consider reporting this to the maintainers of com.cedarsoftware.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Thank you
Eddi

Graph Comparator issue with Set order

#74

I believe this issue still persists when GraphComparator::deepEquals is used. Set comparisons are failing but UnorderedMap comparison with a dummy value succeed

DeepEquals: issue for IGNORE_CUSTOM_EQUALS option

Hi,
I have found a possible issue in DeepEquals utility. It's possible to use the IGNORE_CUSTOM_EQUALS options (if you don't want to use custom equals implementation for specific classes). This option should be Set as it's loaded from options Map on line 176 in DeepEquals utility. But if you look at usage of this set the input parameter of contains method is Class on line 361 (it always be false if any class should be "blacklisted").

Thx.
JS

deepEquals not symmetric

    public static void main(String[] args) {
        class Foo {}

        System.out.println(DeepEquals.deepEquals(new ArrayList<String>(), new Foo())); //this print `false`, as expected
        System.out.println(DeepEquals.deepEquals(new Foo(), new ArrayList<String>())); //but this print `true`
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.