Last active
August 29, 2015 14:09
-
-
Save vdevigere/06676648817f2ae3285d to your computer and use it in GitHub Desktop.
Creating Mixins using Java 8
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
public class Links implements VotableView{ | |
private Votable votable = new VotableImpl(); | |
Votable getVotableInstance(){ | |
return votable; | |
} | |
} |
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
public interface Votable{ | |
public Integer getUps(); | |
public Integer getDowns(); | |
public void setUps(Integer ups); | |
public void setDowns(Integer downs); | |
} |
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
public class VotableImpl implements Votable{ | |
private Integer ups; | |
private Integer downs; | |
@Override | |
public Integer getUps() { | |
return this.ups; | |
} | |
@Override | |
public Integer getDowns() { | |
return this.downs; | |
} | |
public void setUps(Integer ups) { | |
this.ups = ups; | |
} | |
public void setDowns(Integer downs) { | |
this.downs = downs; | |
} | |
} |
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
public interface VotableView extends Votable{ | |
abstract Votable getVotableInstance(); | |
public default Integer getUps(){ | |
getVotableInstance().getUps(); | |
} | |
public Integer getDowns(){ | |
getVotableInstance().getDowns(); | |
} | |
public void setUps(Integer ups){ | |
getVotableInstance().setUps(ups); | |
} | |
public void setDowns(Integer downs){ | |
getVotableInstance().setDowns(downs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment