Note that there are some explanatory texts on larger screens.

plurals
  1. POComparator to compare Map Values
    primarykey
    data
    text
    <p>I have an object with a method who's job it is to compare itself with another method. I've defined a custom comparator inside this method to do the job.</p> <p>The object has a property 'output' which is a <code>Map&lt;String, Map&lt;String, Object&gt;&gt;</code>, basically, I need to find a way to compare the values inside the second map with the other object's map values.</p> <p>The problem I'm having it finding a way to suitably determine whether one object is greater than, less than or equal to another based on the map values. I know it's possible using a bunch of conditions, but that's just not the road I want to go down.</p> <p>An example of the <code>Map&lt;String, Map&lt;String, Object&gt;&gt;</code> property value is:</p> <p><img src="https://i.stack.imgur.com/7LwhU.png" alt="enter image description here"></p> <p>P.S The values of the map will always be numeric.</p> <p>EDIT:</p> <p>Thanks for the responses.</p> <p>In the end I decided to go down the Classes route. Instead of having a <code>Map&lt;String, Map&lt;String, Object&gt;&gt;</code> property I had a <code>List&lt;SystemInformation&gt;</code>, which included a <code>Map&lt;String, Object&gt;</code> property which stored the key/value pairs. </p> <p>I created separate classes for memory, process and file descriptor information respectively and had them subclass the SystemInformation class. I implemented the Comparable interface on the SystemInformation class to compare the properties of two SystemInformation objects.</p> <p>Then I used a very simple weighing algorithm to decide a sort order for separate Reports, by use of a custom Comparator.</p> <p>Cheers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload