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.

PrimitivesModel.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2011 James Moger.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.iciql.test.models;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import java.util.Random;
  20. import com.iciql.Iciql.IQColumn;
  21. import com.iciql.Iciql.IQTable;
  22. /**
  23. * Primitive types model.
  24. */
  25. @IQTable(name = "PrimitivesTest")
  26. public class PrimitivesModel {
  27. @IQColumn(primaryKey = true)
  28. public long myLong;
  29. @IQColumn
  30. public int myInteger;
  31. @IQColumn
  32. public short myShort;
  33. @IQColumn
  34. public byte myByte;
  35. @IQColumn
  36. public boolean myBoolean;
  37. @IQColumn
  38. public double myDouble;
  39. @IQColumn
  40. public float myFloat;
  41. public PrimitivesModel() {
  42. Random rand = new Random();
  43. myLong = rand.nextLong();
  44. myInteger = rand.nextInt();
  45. myShort = (short) rand.nextInt(Short.MAX_VALUE);
  46. myByte = (byte) rand.nextInt(Byte.MAX_VALUE);
  47. myBoolean = rand.nextInt(1) == 1;
  48. myDouble = rand.nextDouble();
  49. myFloat = rand.nextFloat();
  50. }
  51. public boolean equivalentTo(PrimitivesModel p) {
  52. boolean same = true;
  53. same &= myLong == p.myLong;
  54. same &= myInteger == p.myInteger;
  55. same &= myShort == p.myShort;
  56. same &= myByte == p.myByte;
  57. same &= myBoolean == p.myBoolean;
  58. same &= myDouble == p.myDouble;
  59. same &= myFloat == p.myFloat;
  60. return same;
  61. }
  62. public static List<PrimitivesModel> getList() {
  63. List<PrimitivesModel> list = new ArrayList<PrimitivesModel>();
  64. for (int i = 1; i <= 10; i++) {
  65. PrimitivesModel p = new PrimitivesModel();
  66. p.myLong = i;
  67. list.add(p);
  68. }
  69. return list;
  70. }
  71. @Override
  72. public String toString() {
  73. return String.valueOf(myLong);
  74. }
  75. }