You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComplexObject.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2004-2011 H2 Group.
  3. * Copyright 2011 James Moger.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package com.iciql.test.models;
  18. import static com.iciql.Define.primaryKey;
  19. import java.math.BigDecimal;
  20. import java.sql.Time;
  21. import java.sql.Timestamp;
  22. import java.util.Arrays;
  23. import java.util.Date;
  24. import java.util.List;
  25. import com.iciql.Iciql;
  26. /**
  27. * A table containing all possible data types.
  28. */
  29. public class ComplexObject implements Iciql {
  30. public Integer id;
  31. public Long amount;
  32. public String name;
  33. public BigDecimal value;
  34. public Date birthday;
  35. public Time time;
  36. public Timestamp created;
  37. static ComplexObject build(Integer id, boolean isNull) {
  38. ComplexObject obj = new ComplexObject();
  39. obj.id = id;
  40. obj.amount = isNull ? null : Long.valueOf(1);
  41. obj.name = isNull ? null : "hello";
  42. obj.value = isNull ? null : new BigDecimal("1");
  43. obj.birthday = isNull ? null : java.sql.Date.valueOf("2001-01-01");
  44. obj.time = isNull ? null : Time.valueOf("10:20:30");
  45. obj.created = isNull ? null : Timestamp.valueOf("2002-02-02 02:02:02");
  46. return obj;
  47. }
  48. public void defineIQ() {
  49. primaryKey(id);
  50. }
  51. public static List<ComplexObject> getList() {
  52. return Arrays.asList(new ComplexObject[] { build(0, true), build(1, false) });
  53. }
  54. }