Advertisement
MatthijsFontys

My Key value pair class

Dec 24th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public class KeyValuePair<Key, Value> {
  2.  
  3.     private Key key;
  4.     private Value value;
  5.     private final boolean isEmpty;
  6.  
  7.     public KeyValuePair(Key key, Value value){
  8.         this.key = key;
  9.         this.value = value;
  10.         isEmpty = false;
  11.     }
  12.  
  13.     private KeyValuePair(){
  14.         isEmpty = true;
  15.     }
  16.  
  17.     public static KeyValuePair getEmpty(){
  18.         return new KeyValuePair();
  19.     }
  20.  
  21.  
  22.     public Key getKey(){
  23.         return key;
  24.     }
  25.  
  26.     public Value getValue(){
  27.         return value;
  28.     }
  29.  
  30.     public boolean hasValue(){
  31.         return (! isEmpty);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement