Skip to content

Instantly share code, notes, and snippets.

@riking
Created March 25, 2014 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riking/9755808 to your computer and use it in GitHub Desktop.
Save riking/9755808 to your computer and use it in GitHub Desktop.
public interface A {
public int compareTo(A other);
}
public class B implements A {
private String superSecretName;
// other stuff
// NO GETTER for superSecretName
@Override
public int compareTo(A other) {
...
if (!superSecretName.equals(other.superSecretName)) { return 1; }
...
}
}
public class C implements A {
private long superSecretNumber ;
// other stuff
// NO GETTER for superSecretName
@Override
public int compareTo(A other) {
...
if (superSecretNumber != other.superSecretNumber) { return superSecretNumber - other.superSecretNumber; }
...
}
}
public class D extends B, C {
@Override
public int compareTo(A other) {
// Now what?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment