Created
March 25, 2014 05:38
-
-
Save riking/9755808 to your computer and use it in GitHub Desktop.
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
public interface A { | |
public int compareTo(A other); | |
} |
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
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; } | |
... | |
} | |
} |
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
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; } | |
... | |
} | |
} |
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
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