-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create com.epistimis.uddl.utils package
This moves several preexisting utility classes and adds some new ones Includes changes in import statements to account for change of package
- Loading branch information
1 parent
27a7956
commit b5a4185
Showing
24 changed files
with
171 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...m/epistimis/uddl/NavigationUtilities.java → ...stimis/uddl/util/NavigationUtilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../com/epistimis/uddl/NestedCollection.java → ...epistimis/uddl/util/NestedCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* | ||
*/ | ||
package com.epistimis.uddl.util; | ||
|
||
|
||
/** | ||
* An immutable Pair (because values can only be set in the constructor). | ||
* @param <T> | ||
* @param <U> | ||
*/ | ||
public class Pair<T, U> { | ||
|
||
protected T first; | ||
|
||
protected U second; | ||
|
||
public Pair(final T firstElement, final U secondElement) { | ||
this.first = firstElement; | ||
this.second = secondElement; | ||
} | ||
|
||
public T getFirst() { | ||
return first; | ||
} | ||
|
||
public U getSecond() { | ||
return second; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == null) | ||
return false; | ||
if (this == other) | ||
return true; | ||
if (this.getClass().equals(other.getClass())) { | ||
Pair<?, ?> otherPair = (Pair<?, ?>) other; | ||
boolean isEqual = (first == null) ? otherPair.getFirst() == null : first.equals(otherPair.getFirst()); | ||
|
||
if (!isEqual) | ||
return false; | ||
|
||
return (second == null) ? otherPair.getSecond() == null : second.equals(otherPair.getSecond()); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return first == null ? 0 : first.hashCode() + 17 * (second == null ? 0 : second.hashCode()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Pair(" + first + ", " + second + ")"; | ||
} | ||
|
||
/** | ||
* A mutable Pair - values can be reset | ||
* @param <T> | ||
* @param <U> | ||
*/ | ||
public static class Mutable<T,U> extends Pair<T,U> { | ||
|
||
/** | ||
* @param firstElement | ||
* @param secondElement | ||
*/ | ||
public Mutable(T firstElement, U secondElement) { | ||
super(firstElement, secondElement); | ||
// TODO Auto-generated constructor stub | ||
} | ||
public void setFirst(final T firstElement) { first = firstElement; } | ||
public void setSecond(final U secondElement) { second = secondElement; } | ||
|
||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...src/com/epistimis/uddl/ResourceUtils.java → ...om/epistimis/uddl/util/ResourceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
com.epistimis.uddl/src/com/epistimis/uddl/util/Triplet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* | ||
*/ | ||
package com.epistimis.uddl.util; | ||
|
||
|
||
|
||
public class Triplet<T, U, V> { | ||
|
||
private final T first; | ||
private final U second; | ||
private final V third; | ||
|
||
public Triplet(final T firstElement, final U secondElement, final V thirdElement) { | ||
this.first = firstElement; | ||
this.second = secondElement; | ||
this.third = thirdElement; | ||
} | ||
|
||
public T getFirst() { | ||
return first; | ||
} | ||
|
||
public U getSecond() { | ||
return second; | ||
} | ||
|
||
public V getThird() { | ||
return third; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == null) | ||
return false; | ||
if (this == other) | ||
return true; | ||
if (this.getClass().equals(other.getClass())) { | ||
Triplet<?, ?, ?> otherTriplet = (Triplet<?, ?,?>) other; | ||
boolean isEqual = (first == null) ? otherTriplet.getFirst() == null : first.equals(otherTriplet.getFirst()); | ||
|
||
if (!isEqual) | ||
return false; | ||
|
||
isEqual = (second == null) ? otherTriplet.getSecond() == null : second.equals(otherTriplet.getSecond()); | ||
|
||
if (!isEqual) | ||
return false; | ||
|
||
return (third == null) ? otherTriplet.getThird() == null : third.equals(otherTriplet.getThird()); | ||
|
||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return first == null ? 0 : first.hashCode() + 17 * (second == null ? 0 : second.hashCode()) + 347 * (third == null ? 0 : third.hashCode()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Triplet(" + first + ", " + second + ", " + third + ")"; | ||
} | ||
|
||
} |