Skip to content

Instantly share code, notes, and snippets.

@clinuxrulz
Created July 20, 2016 10:18
Show Gist options
  • Save clinuxrulz/105af95a905c45db5ff921deb6f50bb4 to your computer and use it in GitHub Desktop.
Save clinuxrulz/105af95a905c45db5ff921deb6f50bb4 to your computer and use it in GitHub Desktop.
Invariant Functor Use Case
@SuppressWarnings("RedundantTypeArguments")
public static final GuiDSL<GableSoffitParams> gui = GuiDSL.p5(
GuiDSL.<Double, Double, Double, Double, Double>p5(
GuiDSL.labeled("length", GuiDSL.double_()),
GuiDSL.labeled("span", GuiDSL.double_()),
GuiDSL.labeled("height", GuiDSL.double_()),
GuiDSL.labeled("pitch", GuiDSL.double_()),
GuiDSL.labeled("side1Overhang", GuiDSL.double_())
),
GuiDSL.<Double, Double, Double, Double, Double>p5(
GuiDSL.labeled("side2Overhang", GuiDSL.double_()),
GuiDSL.labeled("end1Overhang", GuiDSL.double_()),
GuiDSL.labeled("end2Overhang", GuiDSL.double_()),
GuiDSL.labeled("overhangKneeHeight", GuiDSL.double_()),
GuiDSL.labeled("purlinHeight", GuiDSL.double_())
),
GuiDSL.<Boolean, String, String, String, String>p5(
GuiDSL.checkBox("cyclonic"),
GuiDSL.labeled("soffitSheetingItemName", GuiDSL.string()),
GuiDSL.labeled("soffitSheetingColourName", GuiDSL.string()),
GuiDSL.labeled("wallSheetingColourName", GuiDSL.string()),
GuiDSL.labeled("gutterColourName", GuiDSL.string())
),
GuiDSL.<String, Double, Integer, Integer, Integer>p5(
GuiDSL.labeled("bargeColourName", GuiDSL.string()),
GuiDSL.labeled("maxFlashingLength", GuiDSL.double_()),
GuiDSL.labeled("numSide1WallStuds", GuiDSL.int_()),
GuiDSL.labeled("numSide2WallStuds", GuiDSL.int_()),
GuiDSL.labeled("numEnd1WallStuds", GuiDSL.int_())
),
GuiDSL.<Integer,Integer, Integer>p3(
GuiDSL.labeled("numEnd2WallStuds", GuiDSL.int_()),
GuiDSL.labeled("numSide1Purlins", GuiDSL.int_()),
GuiDSL.labeled("numSide2Purlins", GuiDSL.int_())
)
).invmap(
x ->
GableSoffitParams
.with()
.length(x._1()._1())
.span(x._1()._2())
.height(x._1()._3())
.pitch(x._1()._4())
.side1Overhang(x._1()._5())
.side2Overhang(x._2()._1())
.end1Overhang(x._2()._2())
.end2Overhang(x._2()._3())
.overhangKneeHeight(x._2()._4())
.purlinHeight(x._2()._5())
.cyclonic(x._3()._1())
.soffitSheetingItemName(x._3()._2())
.soffitSheetingColourName(x._3()._3())
.wallSheetingColourName(x._3()._4())
.gutterColourName(x._3()._5())
.bargeColourName(x._4()._1())
.maxFlashingLength(x._4()._2())
.numSide1WallStuds(x._4()._3())
.numSide2WallStuds(x._4()._4())
.numEnd1WallStuds(x._4()._5())
.numEnd2WallStuds(x._5()._1())
.numSide1Purlins(x._5()._2())
.numSide2Purlins(x._5()._3())
.build(),
x ->
P.p(
P.p(
x.length(),
x.span(),
x.height(),
x.pitch(),
x.side1Overhang()
),
P.p(
x.side2Overhang(),
x.end1Overhang(),
x.end2Overhang(),
x.overhangKneeHeight(),
x.purlinHeight()
),
P.p(
x.cyclonic(),
x.soffitSheetingItemName(),
x.soffitSheetingColourName(),
x.wallSheetingColourName(),
x.gutterColourName()
),
P.p(
x.bargeColourName(),
x.maxFlashingLength(),
x.numSide1WallStuds(),
x.numSide2WallStuds(),
x.numEnd1WallStuds()
),
P.p(
x.numEnd2WallStuds(),
x.numSide1Purlins(),
x.numSide2Purlins()
)
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment