1 9 package org.jscience.mathematics.functions; 10 11 import javolution.lang.Reference; 12 import javolution.context.LocalContext; 13 14 27 public interface Variable<X> extends Reference<X> { 28 29 34 String getSymbol(); 35 36 42 public static class Local<X> implements Variable<X> { 43 44 47 private X _value; 48 49 52 private final String _symbol; 53 54 59 public Local(String symbol) { 60 _symbol = symbol; 61 } 62 63 public String getSymbol() { 64 return _symbol; 65 } 66 67 public X get() { 68 return _value; 69 } 70 71 public void set(X arg0) { 72 _value = arg0; 73 } 74 } 75 76 101 public static class Global<X> implements Variable<X> { 102 103 106 private LocalContext.Reference<X> _value = new LocalContext.Reference<X>(); 107 108 111 private final String _symbol; 112 113 118 public Global(String symbol) { 119 _symbol = symbol; 120 } 121 122 public String getSymbol() { 123 return _symbol; 124 } 125 126 public X get() { 127 return _value.get(); 128 } 129 130 public void set(X arg0) { 131 _value.set(arg0); 132 } 133 } 134 135 } | Popular Tags |