Skip to content

Commit

Permalink
Mindless javadoc improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
manning committed Jul 28, 2023
1 parent 7f0d8a4 commit 61e4ae1
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions src/edu/stanford/nlp/util/Pair.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.stanford.nlp.util;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.Serial;
import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -105,10 +105,10 @@ public static <X, Y> Pair<X, Y> makePair(X x, Y y) {

/**
* Write a string representation of a Pair to a DataStream.
* The <code>toString()</code> method is called on each of the pair
* of objects and a <code>String</code> representation is written.
* The {@code toString()} method is called on each of the pair
* of objects and a {@code String} representation is written.
* This might not allow one to recover the pair of objects unless they
* are of type <code>String</code>.
* are of type {@code String}.
*/
public void save(DataOutputStream out) {
try {
Expand All @@ -120,24 +120,24 @@ public void save(DataOutputStream out) {
}

/**
* Compares this <code>Pair</code> to another object.
* If the object is a <code>Pair</code>, this function will work providing
* the elements of the <code>Pair</code> are themselves comparable.
* Compares this {@code Pair} to another object.
* If the object is a {@code Pair}, this function will work providing
* the elements of the {@code Pair} are themselves comparable.
* It will then return a value based on the pair of objects, where
* <code>p &gt; q iff p.first() &gt; q.first() ||
* (p.first().equals(q.first()) && p.second() &gt; q.second())</code>.
* If the other object is not a <code>Pair</code>, it throws a
* <code>ClassCastException</code>.
* If the other object is not a {@code Pair}, it throws a
* {@code ClassCastException}.
*
* @param another the <code>Object</code> to be compared.
* @return the value <code>0</code> if the argument is a
* <code>Pair</code> equal to this <code>Pair</code>; a value less than
* <code>0</code> if the argument is a <code>Pair</code>
* greater than this <code>Pair</code>; and a value
* {@code Pair} equal to this {@code Pair}; a value less than
* <code>0</code> if the argument is a {@code Pair}
* greater than this {@code Pair}; and a value
* greater than <code>0</code> if the argument is a
* <code>Pair</code> less than this <code>Pair</code>.
* {@code Pair} less than this {@code Pair}.
* @throws ClassCastException if the argument is not a
* <code>Pair</code>.
* {@code Pair}.
* @see java.lang.Comparable
*/
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -196,6 +196,7 @@ public static Pair<String, String> internedStringPair(String first, String secon
/**
* use serialVersionUID for cross version serialization compatibility
*/
@Serial
private static final long serialVersionUID = 1360822168806852921L;


Expand All @@ -211,6 +212,7 @@ private MutableInternedPair(String first, String second) {
internStrings();
}

@Serial
protected Object readResolve() {
internStrings();
return this;
Expand All @@ -226,6 +228,7 @@ private void internStrings() {
}

// use serialVersionUID for cross version serialization compatibility
@Serial
private static final long serialVersionUID = 1360822168806852922L;

}
Expand All @@ -238,10 +241,10 @@ public void prettyLog(RedwoodChannels channels, String description) {
}

/**
* Compares a <code>Pair</code> to another <code>Pair</code> according to the first object of the pair only
* This function will work providing
* the first element of the <code>Pair</code> is comparable, otherwise will throw a
* <code>ClassCastException</code>
* Compares a {@code Pair} to another {@code Pair} according to the first object of the pair only
* This function will work providing the first element of the {@code Pair} is comparable,
* otherwise will throw a {@code ClassCastException}.
*
* @author jonathanberant
*/
public static class ByFirstPairComparator<T1,T2> implements Comparator<Pair<T1,T2>> {
Expand All @@ -254,9 +257,9 @@ public int compare(Pair<T1, T2> pair1, Pair<T1, T2> pair2) {
}

/**
* Compares a <code>Pair</code> to another <code>Pair</code> according to the first object of the pair only in decreasing order
* Compares a {@code Pair} to another {@code Pair} according to the first object of the pair only in decreasing order
* This function will work providing
* the first element of the <code>Pair</code> is comparable, otherwise will throw a
* the first element of the {@code Pair} is comparable, otherwise will throw a
* <code>ClassCastException</code>
* @author jonathanberant
*/
Expand All @@ -270,9 +273,9 @@ public int compare(Pair<T1, T2> pair1, Pair<T1, T2> pair2) {
}

/**
* Compares a <code>Pair</code> to another <code>Pair</code> according to the second object of the pair only
* Compares a {@code Pair} to another {@code Pair} according to the second object of the pair only
* This function will work providing
* the first element of the <code>Pair</code> is comparable, otherwise will throw a
* the first element of the {@code Pair} is comparable, otherwise will throw a
* <code>ClassCastException</code>
* @author jonathanberant
*/
Expand All @@ -286,10 +289,11 @@ public int compare(Pair<T1, T2> pair1, Pair<T1, T2> pair2) {
}

/**
* Compares a <code>Pair</code> to another <code>Pair</code> according to the second object of the pair only in decreasing order
* Compares a {@code Pair} to another {@code Pair} according to the second object of the pair only in decreasing order
* This function will work providing
* the first element of the <code>Pair</code> is comparable, otherwise will throw a
* the first element of the {@code Pair} is comparable, otherwise will throw a
* <code>ClassCastException</code>
*
* @author jonathanberant
*/
public static class BySecondReversePairComparator<T1,T2> implements Comparator<Pair<T1,T2>> {
Expand Down

0 comments on commit 61e4ae1

Please sign in to comment.