PageRenderTime 38ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/com/google/appengine/datanucleus/test/HasOneToManyStringPkListJDO.java

http://datanucleus-appengine.googlecode.com/
Java | 156 lines | 103 code | 35 blank | 18 comment | 0 complexity | 84f07bf58e857cf0e4f09897f406ea95 MD5 | raw file
Possible License(s): Apache-2.0
  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus.test;
  14. import java.util.ArrayList;
  15. import java.util.Collection;
  16. import java.util.List;
  17. import javax.jdo.annotations.Element;
  18. import javax.jdo.annotations.PersistenceCapable;
  19. import javax.jdo.annotations.Persistent;
  20. import javax.jdo.annotations.PrimaryKey;
  21. /**
  22. * @author Max Ross <maxr@google.com>
  23. */
  24. @PersistenceCapable(detachable = "true")
  25. public class HasOneToManyStringPkListJDO {
  26. @PrimaryKey
  27. private String id;
  28. @Persistent
  29. private String val;
  30. public String getId() {
  31. return id;
  32. }
  33. public void setId(String id) {
  34. this.id = id;
  35. }
  36. @Persistent(mappedBy = "parent")
  37. @Element(dependent = "true")
  38. private List<BidirectionalChildStringPkListJDO> bidirChildren = new ArrayList<BidirectionalChildStringPkListJDO>();
  39. @Element(dependent = "true")
  40. private List<Flight> flights = new ArrayList<Flight>();
  41. @Element(dependent = "true")
  42. private List<HasKeyPkJDO> hasKeyPks = new ArrayList<HasKeyPkJDO>();
  43. public List<BidirectionalChildJDO> getBidirChildren() {
  44. return (List) bidirChildren;
  45. }
  46. public void addBidirChild(BidirectionalChildStringPkListJDO bidirChild) {
  47. bidirChildren.add(bidirChild);
  48. }
  49. public List<Flight> getFlights() {
  50. return flights;
  51. }
  52. public void addFlight(Flight flight) {
  53. this.flights.add(flight);
  54. }
  55. public List<HasKeyPkJDO> getHasKeyPks() {
  56. return hasKeyPks;
  57. }
  58. public void addHasKeyPk(HasKeyPkJDO hasKeyPk) {
  59. this.hasKeyPks.add(hasKeyPk);
  60. }
  61. public String getVal() {
  62. return val;
  63. }
  64. public void setVal(String val) {
  65. this.val = val;
  66. }
  67. public void nullBidirChildren() {
  68. bidirChildren = null;
  69. }
  70. public void nullFlights() {
  71. flights = null;
  72. }
  73. public void nullHasKeyPks() {
  74. hasKeyPks = null;
  75. }
  76. public void clearBidirChildren() {
  77. bidirChildren.clear();
  78. }
  79. public void clearFlights() {
  80. flights.clear();
  81. }
  82. public void clearHasKeyPks() {
  83. hasKeyPks.clear();
  84. }
  85. public void addBidirChildAtPosition(BidirectionalChildStringPkListJDO bidir, int pos) {
  86. bidirChildren.set(pos, bidir);
  87. }
  88. public void addFlightAtPosition(Flight f, int pos) {
  89. flights.set(pos, f);
  90. }
  91. public void addHasKeyPkAtPosition(HasKeyPkJDO hasKeyPk, int pos) {
  92. hasKeyPks.set(pos, hasKeyPk);
  93. }
  94. public void removeBidirChildAtPosition(int i) {
  95. bidirChildren.remove(i);
  96. }
  97. public void removeFlightAtPosition(int i) {
  98. flights.remove(i);
  99. }
  100. public void removeHasKeyPkAtPosition(int i) {
  101. hasKeyPks.remove(i);
  102. }
  103. public void addAtPosition(int i, BidirectionalChildStringPkListJDO bidir) {
  104. bidirChildren.add(i, bidir);
  105. }
  106. public void addAtPosition(int i, Flight f) {
  107. flights.add(i, f);
  108. }
  109. public void addAtPosition(int i, HasKeyPkJDO hasKeyPk) {
  110. hasKeyPks.add(i, hasKeyPk);
  111. }
  112. public void removeFlights(Collection<Flight> flights) {
  113. this.flights.removeAll(flights);
  114. }
  115. public void removeBidirChildren(Collection<BidirectionalChildJDO> bidirChildren) {
  116. this.bidirChildren.removeAll(bidirChildren);
  117. }
  118. }