1 18 19 package org.sablecc.sablecc.alphabet; 20 21 import java.math.BigInteger ; 22 23 public class Realms { 24 25 private static final AdjacencyRealm<Integer > integer = new AdjacencyRealm<Integer >() { 26 27 @Override 28 public boolean isAdjacent( 29 Integer bound1, 30 Integer bound2) { 31 32 return bound1 + 1 == bound2; 33 } 34 35 @Override 36 public Integer next( 37 Integer bound) { 38 39 return bound + 1; 40 } 41 42 @Override 43 public Integer previous( 44 Integer bound) { 45 46 return bound - 1; 47 } 48 }; 49 50 private static final AdjacencyRealm<BigInteger > bigInteger = new AdjacencyRealm<BigInteger >() { 51 52 @Override 53 public boolean isAdjacent( 54 BigInteger bound1, 55 BigInteger bound2) { 56 57 return bound1.add(BigInteger.ONE).equals(bound2); 58 } 59 60 @Override 61 public BigInteger next( 62 BigInteger bound) { 63 64 return bound.add(BigInteger.ONE); 65 } 66 67 @Override 68 public BigInteger previous( 69 BigInteger bound) { 70 71 return bound.subtract(BigInteger.ONE); 72 } 73 74 }; 75 76 private static final AdjacencyRealm<Character > character = new AdjacencyRealm<Character >() { 77 78 @Override 79 public boolean isAdjacent( 80 Character bound1, 81 Character bound2) { 82 83 return bound1 + 1 == bound2; 84 } 85 86 @Override 87 public Character next( 88 Character bound) { 89 90 return (char) (bound + 1); 91 } 92 93 @Override 94 public Character previous( 95 Character bound) { 96 97 return (char) (bound - 1); 98 } 99 100 }; 101 102 public static AdjacencyRealm<BigInteger > getBigInteger() { 103 104 return bigInteger; 105 } 106 107 public static AdjacencyRealm<Integer > getInteger() { 108 109 return integer; 110 } 111 112 public static AdjacencyRealm<Character > getCharacter() { 113 114 return character; 115 } 116 117 } 118 | Popular Tags |