Created
July 28, 2012 23:32
-
-
Save nh2/3195264 to your computer and use it in GitHub Desktop.
StaticPipeline in Java (not working)
This file contains hidden or 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
package staticpipeline; | |
class Image implements ProvidesOriginalImage { | |
@Override | |
public Image getOriginalImage() { | |
return null; | |
} | |
} | |
class FaceLocation implements ProvidesFaceLocation { | |
@Override | |
public EyeLocation getFaceLocation() { | |
return null; | |
} | |
} | |
class EyeLocation implements ProvidesEyeLocation { | |
@Override | |
public EyeLocation getEyeLocation() { | |
return null; | |
} | |
} | |
interface ProvidesOriginalImage { | |
Image getOriginalImage(); | |
} | |
interface ProvidesProcessedImage { | |
Image getProcessedImage(); | |
} | |
interface ProvidesFaceLocation { | |
EyeLocation getFaceLocation(); | |
} | |
interface ProvidesEyeLocation { | |
EyeLocation getEyeLocation(); | |
} | |
interface FaceDetectionResult extends ProvidesOriginalImage, | |
ProvidesProcessedImage, ProvidesFaceLocation { | |
} | |
interface EyeDetectionInput extends ProvidesOriginalImage, | |
ProvidesProcessedImage, ProvidesFaceLocation { | |
} | |
interface EyeDetectionResult extends ProvidesOriginalImage, | |
ProvidesProcessedImage, ProvidesEyeLocation { | |
} | |
class FaceDetector { | |
FaceDetectionResult detectFace(ProvidesOriginalImage i) { | |
return null; | |
} | |
} | |
class EyeDetector { | |
EyeDetectionResult detectEyes(EyeDetectionInput i) { | |
return null; | |
} | |
} | |
public class StaticPipeline { | |
@SuppressWarnings("unused") | |
public static void main(String[] args) { | |
Image i = new Image(); | |
FaceDetector fd = new FaceDetector(); | |
EyeDetector ed = new EyeDetector(); | |
/* | |
* And finally, this doesn't work, because FaceDetectionResult is not | |
* the same as EyeDetectionInput for Java, although they extend exactly | |
* the same interfaces. | |
* | |
* ("The method detectEyes(EyeDetectionInput) in the type EyeDetector is | |
* not applicable for the arguments (FaceDetectionResult)") | |
*/ | |
// ed.detectEyes(fd.detectFace(i)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment