Facebook
From Abrupt Owl, 9 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 639
  1. public class Goolean{
  2.    
  3.     private final Boolean value;
  4.  
  5.     public Goolean(boolean theValue) {
  6.         value = theValue;
  7.     }
  8.    
  9.     public Goolean whenTrue(Consumer<Void> alternative){
  10.         if( value ){
  11.             alternative.accept(null);
  12.         }
  13.         return this;
  14.     }
  15.    
  16.      public Goolean whenFalse(Consumer<Void> alternative){
  17.         if( !value ){
  18.             alternative.accept(null);
  19.         }
  20.         return this;
  21.     }
  22.      
  23.     public Goolean or(Goolean other){
  24.         return or(other.value);
  25.     }
  26.    
  27.     public Goolean or(boolean other){
  28.         return new Goolean(value || other);
  29.     }
  30.    
  31.     public Boolean getValue(){
  32.         return value;
  33.     }
  34.    
  35.     public Goolean and(boolean other){
  36.         return new Goolean(value && other);
  37.     }
  38.    
  39.     public Goolean and(Goolean other){
  40.         return and(other.value);
  41.     }
  42.    
  43.     public Goolean or(Function<Boolean,Boolean> alternative){
  44.         return or(new Goolean(alternative.apply(value)));
  45.     }
  46.    
  47.     public Goolean and(Function<Boolean,Boolean> alternative){
  48.         return and(new Goolean(alternative.apply(value)));
  49.     }
  50.    
  51.    
  52. }
  53.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Gracious Water Vole java 9 Years ago.