/projects/OG-Language/Client/src/com/opengamma/language/function/Available.java

https://github.com/gsteri1/OG-Platform · Java · 254 lines · 247 code · 0 blank · 7 comment · 88 complexity · 3f1b94c1c1201715796dffa2a6793754 MD5 · raw file

  1. // Automatically created - do not modify
  2. ///CLOVER:OFF
  3. // CSOFF: Generated File
  4. package com.opengamma.language.function;
  5. public class Available extends com.opengamma.language.connector.Function implements java.io.Serializable {
  6. private static final long serialVersionUID = 43552799486l;
  7. public static class Entry implements java.io.Serializable {
  8. private static final long serialVersionUID = -48247048773915l;
  9. private int _identifier;
  10. public static final String IDENTIFIER_KEY = "identifier";
  11. private com.opengamma.language.function.Definition _definition;
  12. public static final String DEFINITION_KEY = "definition";
  13. public Entry (int identifier, com.opengamma.language.function.Definition definition) {
  14. _identifier = identifier;
  15. if (definition == null) throw new NullPointerException ("'definition' cannot be null");
  16. else {
  17. _definition = (com.opengamma.language.function.Definition)definition.clone ();
  18. }
  19. }
  20. protected Entry (final org.fudgemsg.mapping.FudgeDeserializer deserializer, final org.fudgemsg.FudgeMsg fudgeMsg) {
  21. org.fudgemsg.FudgeField fudgeField;
  22. fudgeField = fudgeMsg.getByName (IDENTIFIER_KEY);
  23. if (fudgeField == null) throw new IllegalArgumentException ("Fudge message is not a Entry - field 'identifier' is not present");
  24. try {
  25. _identifier = fudgeMsg.getFieldValue (Integer.class, fudgeField);
  26. }
  27. catch (IllegalArgumentException e) {
  28. throw new IllegalArgumentException ("Fudge message is not a Entry - field 'identifier' is not integer", e);
  29. }
  30. fudgeField = fudgeMsg.getByName (DEFINITION_KEY);
  31. if (fudgeField == null) throw new IllegalArgumentException ("Fudge message is not a Entry - field 'definition' is not present");
  32. try {
  33. _definition = com.opengamma.language.function.Definition.fromFudgeMsg (deserializer, fudgeMsg.getFieldValue (org.fudgemsg.FudgeMsg.class, fudgeField));
  34. }
  35. catch (IllegalArgumentException e) {
  36. throw new IllegalArgumentException ("Fudge message is not a Entry - field 'definition' is not Definition message", e);
  37. }
  38. }
  39. protected Entry (final Entry source) {
  40. if (source == null) throw new NullPointerException ("'source' must not be null");
  41. _identifier = source._identifier;
  42. if (source._definition == null) _definition = null;
  43. else {
  44. _definition = (com.opengamma.language.function.Definition)source._definition.clone ();
  45. }
  46. }
  47. public Entry clone () {
  48. return new Entry (this);
  49. }
  50. public org.fudgemsg.FudgeMsg toFudgeMsg (final org.fudgemsg.mapping.FudgeSerializer serializer) {
  51. if (serializer == null) throw new NullPointerException ("serializer must not be null");
  52. final org.fudgemsg.MutableFudgeMsg msg = serializer.newMessage ();
  53. toFudgeMsg (serializer, msg);
  54. return msg;
  55. }
  56. public void toFudgeMsg (final org.fudgemsg.mapping.FudgeSerializer serializer, final org.fudgemsg.MutableFudgeMsg msg) {
  57. msg.add (IDENTIFIER_KEY, null, _identifier);
  58. if (_definition != null) {
  59. final org.fudgemsg.MutableFudgeMsg fudge1 = org.fudgemsg.mapping.FudgeSerializer.addClassHeader (serializer.newMessage (), _definition.getClass (), com.opengamma.language.function.Definition.class);
  60. _definition.toFudgeMsg (serializer, fudge1);
  61. msg.add (DEFINITION_KEY, null, fudge1);
  62. }
  63. }
  64. public static Entry fromFudgeMsg (final org.fudgemsg.mapping.FudgeDeserializer deserializer, final org.fudgemsg.FudgeMsg fudgeMsg) {
  65. final java.util.List<org.fudgemsg.FudgeField> types = fudgeMsg.getAllByOrdinal (0);
  66. for (org.fudgemsg.FudgeField field : types) {
  67. final String className = (String)field.getValue ();
  68. if ("com.opengamma.language.function.Available.Entry".equals (className)) break;
  69. try {
  70. return (com.opengamma.language.function.Available.Entry)Class.forName (className).getDeclaredMethod ("fromFudgeMsg", org.fudgemsg.mapping.FudgeDeserializer.class, org.fudgemsg.FudgeMsg.class).invoke (null, deserializer, fudgeMsg);
  71. }
  72. catch (Throwable t) {
  73. // no-action
  74. }
  75. }
  76. return new Entry (deserializer, fudgeMsg);
  77. }
  78. public int getIdentifier () {
  79. return _identifier;
  80. }
  81. public void setIdentifier (int identifier) {
  82. _identifier = identifier;
  83. }
  84. public com.opengamma.language.function.Definition getDefinition () {
  85. return _definition;
  86. }
  87. public void setDefinition (com.opengamma.language.function.Definition definition) {
  88. if (definition == null) throw new NullPointerException ("'definition' cannot be null");
  89. else {
  90. _definition = (com.opengamma.language.function.Definition)definition.clone ();
  91. }
  92. }
  93. public boolean equals (final Object o) {
  94. if (o == this) return true;
  95. if (!(o instanceof Entry)) return false;
  96. Entry msg = (Entry)o;
  97. if (_identifier != msg._identifier) return false;
  98. if (_definition != null) {
  99. if (msg._definition != null) {
  100. if (!_definition.equals (msg._definition)) return false;
  101. }
  102. else return false;
  103. }
  104. else if (msg._definition != null) return false;
  105. return true;
  106. }
  107. public int hashCode () {
  108. int hc = 1;
  109. hc = (hc * 31) + (int)_identifier;
  110. hc *= 31;
  111. if (_definition != null) hc += _definition.hashCode ();
  112. return hc;
  113. }
  114. public String toString () {
  115. return org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(this, org.apache.commons.lang.builder.ToStringStyle.SHORT_PREFIX_STYLE);
  116. }
  117. }
  118. private java.util.List<com.opengamma.language.function.Available.Entry> _function;
  119. public static final String FUNCTION_KEY = "function";
  120. public Available () {
  121. }
  122. protected Available (final org.fudgemsg.mapping.FudgeDeserializer deserializer, final org.fudgemsg.FudgeMsg fudgeMsg) {
  123. super (deserializer, fudgeMsg);
  124. java.util.List<org.fudgemsg.FudgeField> fudgeFields;
  125. fudgeFields = fudgeMsg.getAllByName (FUNCTION_KEY);
  126. if (fudgeFields.size () > 0) {
  127. final java.util.List<com.opengamma.language.function.Available.Entry> fudge1;
  128. fudge1 = new java.util.ArrayList<com.opengamma.language.function.Available.Entry> (fudgeFields.size ());
  129. for (org.fudgemsg.FudgeField fudge2 : fudgeFields) {
  130. try {
  131. final com.opengamma.language.function.Available.Entry fudge3;
  132. fudge3 = com.opengamma.language.function.Available.Entry.fromFudgeMsg (deserializer, fudgeMsg.getFieldValue (org.fudgemsg.FudgeMsg.class, fudge2));
  133. fudge1.add (fudge3);
  134. }
  135. catch (IllegalArgumentException e) {
  136. throw new IllegalArgumentException ("Fudge message is not a Available - field 'function' is not Entry message", e);
  137. }
  138. }
  139. setFunction (fudge1);
  140. }
  141. }
  142. public Available (java.util.Collection<? extends com.opengamma.language.function.Available.Entry> function) {
  143. if (function == null) _function = null;
  144. else {
  145. final java.util.List<com.opengamma.language.function.Available.Entry> fudge0 = new java.util.ArrayList<com.opengamma.language.function.Available.Entry> (function);
  146. for (java.util.ListIterator<com.opengamma.language.function.Available.Entry> fudge1 = fudge0.listIterator (); fudge1.hasNext (); ) {
  147. com.opengamma.language.function.Available.Entry fudge2 = fudge1.next ();
  148. if (fudge2 == null) throw new NullPointerException ("List element of 'function' cannot be null");
  149. fudge1.set ((com.opengamma.language.function.Available.Entry)fudge2.clone ());
  150. }
  151. _function = fudge0;
  152. }
  153. }
  154. protected Available (final Available source) {
  155. super (source);
  156. if (source == null) throw new NullPointerException ("'source' must not be null");
  157. if (source._function == null) _function = null;
  158. else {
  159. final java.util.List<com.opengamma.language.function.Available.Entry> fudge0 = new java.util.ArrayList<com.opengamma.language.function.Available.Entry> (source._function);
  160. for (java.util.ListIterator<com.opengamma.language.function.Available.Entry> fudge1 = fudge0.listIterator (); fudge1.hasNext (); ) {
  161. com.opengamma.language.function.Available.Entry fudge2 = fudge1.next ();
  162. fudge1.set ((com.opengamma.language.function.Available.Entry)fudge2.clone ());
  163. }
  164. _function = fudge0;
  165. }
  166. }
  167. public Available clone () {
  168. return new Available (this);
  169. }
  170. public org.fudgemsg.FudgeMsg toFudgeMsg (final org.fudgemsg.mapping.FudgeSerializer serializer) {
  171. if (serializer == null) throw new NullPointerException ("serializer must not be null");
  172. final org.fudgemsg.MutableFudgeMsg msg = serializer.newMessage ();
  173. toFudgeMsg (serializer, msg);
  174. return msg;
  175. }
  176. public void toFudgeMsg (final org.fudgemsg.mapping.FudgeSerializer serializer, final org.fudgemsg.MutableFudgeMsg msg) {
  177. super.toFudgeMsg (serializer, msg);
  178. if (_function != null) {
  179. for (com.opengamma.language.function.Available.Entry fudge1 : _function) {
  180. final org.fudgemsg.MutableFudgeMsg fudge2 = org.fudgemsg.mapping.FudgeSerializer.addClassHeader (serializer.newMessage (), fudge1.getClass (), com.opengamma.language.function.Available.Entry.class);
  181. fudge1.toFudgeMsg (serializer, fudge2);
  182. msg.add (FUNCTION_KEY, null, fudge2);
  183. }
  184. }
  185. }
  186. public static Available fromFudgeMsg (final org.fudgemsg.mapping.FudgeDeserializer deserializer, final org.fudgemsg.FudgeMsg fudgeMsg) {
  187. final java.util.List<org.fudgemsg.FudgeField> types = fudgeMsg.getAllByOrdinal (0);
  188. for (org.fudgemsg.FudgeField field : types) {
  189. final String className = (String)field.getValue ();
  190. if ("com.opengamma.language.function.Available".equals (className)) break;
  191. try {
  192. return (com.opengamma.language.function.Available)Class.forName (className).getDeclaredMethod ("fromFudgeMsg", org.fudgemsg.mapping.FudgeDeserializer.class, org.fudgemsg.FudgeMsg.class).invoke (null, deserializer, fudgeMsg);
  193. }
  194. catch (Throwable t) {
  195. // no-action
  196. }
  197. }
  198. return new Available (deserializer, fudgeMsg);
  199. }
  200. public java.util.List<com.opengamma.language.function.Available.Entry> getFunction () {
  201. if (_function != null) {
  202. return java.util.Collections.unmodifiableList (_function);
  203. }
  204. else return null;
  205. }
  206. public void setFunction (com.opengamma.language.function.Available.Entry function) {
  207. if (function == null) _function = null;
  208. else {
  209. _function = new java.util.ArrayList<com.opengamma.language.function.Available.Entry> (1);
  210. addFunction (function);
  211. }
  212. }
  213. public void setFunction (java.util.Collection<? extends com.opengamma.language.function.Available.Entry> function) {
  214. if (function == null) _function = null;
  215. else {
  216. final java.util.List<com.opengamma.language.function.Available.Entry> fudge0 = new java.util.ArrayList<com.opengamma.language.function.Available.Entry> (function);
  217. for (java.util.ListIterator<com.opengamma.language.function.Available.Entry> fudge1 = fudge0.listIterator (); fudge1.hasNext (); ) {
  218. com.opengamma.language.function.Available.Entry fudge2 = fudge1.next ();
  219. if (fudge2 == null) throw new NullPointerException ("List element of 'function' cannot be null");
  220. fudge1.set ((com.opengamma.language.function.Available.Entry)fudge2.clone ());
  221. }
  222. _function = fudge0;
  223. }
  224. }
  225. public void addFunction (com.opengamma.language.function.Available.Entry function) {
  226. if (function == null) throw new NullPointerException ("'function' cannot be null");
  227. if (_function == null) _function = new java.util.ArrayList<com.opengamma.language.function.Available.Entry> ();
  228. _function.add ((com.opengamma.language.function.Available.Entry)function.clone ());
  229. }
  230. public boolean equals (final Object o) {
  231. if (o == this) return true;
  232. if (!(o instanceof Available)) return false;
  233. Available msg = (Available)o;
  234. if (_function != null) {
  235. if (msg._function != null) {
  236. if (!_function.equals (msg._function)) return false;
  237. }
  238. else return false;
  239. }
  240. else if (msg._function != null) return false;
  241. return super.equals (msg);
  242. }
  243. public int hashCode () {
  244. int hc = super.hashCode ();
  245. hc *= 31;
  246. if (_function != null) hc += _function.hashCode ();
  247. return hc;
  248. }
  249. public String toString () {
  250. return org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(this, org.apache.commons.lang.builder.ToStringStyle.SHORT_PREFIX_STYLE);
  251. }
  252. }
  253. ///CLOVER:ON
  254. // CSON: Generated File