Skip to content

Commit

Permalink
added view comparators
Browse files Browse the repository at this point in the history
  • Loading branch information
astrapi69 committed May 8, 2019
1 parent e13a478 commit d7b28fe
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* The MIT License
*
* Copyright (C) 2015 Asterios Raptis
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package de.alpharogroup.collection.comparators;

import java.util.Comparator;

import de.alpharogroup.collections.pairs.KeyMapPair;

/**
* The class {@link KeyMapPairKeyComparator} compares {@linkplain KeyMapPair} objects over the key
* where the key have to implements the {@linkplain Comparable} interface.
*
* @param <K>
* The type of the key.
* @param <MK>
* the generic type of the map key.
* @param <MV>
* the generic type of the map value.
*/
public class KeyMapPairKeyComparator<K extends Comparable<K>, MK, MV>
implements
Comparator<KeyMapPair<K, MK, MV>>
{

/**
* {@inheritDoc}
*/
@Override
public int compare(final KeyMapPair<K, MK, MV> o1, final KeyMapPair<K, MK, MV> o2)
{
return o1.getKey().compareTo(o2.getKey());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* The MIT License
*
* Copyright (C) 2015 Asterios Raptis
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package de.alpharogroup.collection.comparators;

import java.util.Comparator;

import de.alpharogroup.collections.pairs.KeyValuePair;

/**
* The class {@link KeyValuePairKeyComparator} compares {@linkplain KeyValuePair} objects over the
* key where the key have to implements the {@linkplain Comparable} interface.
*
* @param <K>
* The generic type of the key
* @param <V>
* The generic type of the value
*/
public class KeyValuePairKeyComparator<K extends Comparable<K>, V>
implements
Comparator<KeyValuePair<K, V>>
{

/**
* {@inheritDoc}
*/
@Override
public int compare(final KeyValuePair<K, V> o1, final KeyValuePair<K, V> o2)
{
return o1.getKey().compareTo(o2.getKey());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* The MIT License
*
* Copyright (C) 2015 Asterios Raptis
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package de.alpharogroup.collection.comparators;

import java.util.Comparator;

import de.alpharogroup.collections.pairs.KeyValuesPair;

/**
* The class {@link KeyValuesPairKeyComparator} compares {@linkplain KeyValuesPair} objects over the
* key where the key have to implements the {@linkplain Comparable} interface.
*
* @param <K>
* The generic type of the key
* @param <V>
* The generic type of the value
*/
public class KeyValuesPairKeyComparator<K extends Comparable<K>, V>
implements
Comparator<KeyValuesPair<K, V>>
{

/**
* {@inheritDoc}
*/
@Override
public int compare(final KeyValuesPair<K, V> o1, final KeyValuesPair<K, V> o2)
{
return o1.getKey().compareTo(o2.getKey());
}
}
11 changes: 11 additions & 0 deletions src/main/java/de/alpharogroup/collection/comparators/package.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
de.alpharogroup.comparators
</title>
</head>
<body>
This package contains common comparators
</body>
</html>

0 comments on commit d7b28fe

Please sign in to comment.