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

http://datanucleus-appengine.googlecode.com/ · Java · 166 lines · 113 code · 35 blank · 18 comment · 4 complexity · 3f9122bce7c0e5d8f85c9b77df1eebaa MD5 · raw file

  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.Collection;
  15. import java.util.HashSet;
  16. import java.util.Set;
  17. import javax.jdo.annotations.Element;
  18. import javax.jdo.annotations.Extension;
  19. import javax.jdo.annotations.IdGeneratorStrategy;
  20. import javax.jdo.annotations.PersistenceCapable;
  21. import javax.jdo.annotations.Persistent;
  22. import javax.jdo.annotations.PrimaryKey;
  23. /**
  24. * @author Max Ross <maxr@google.com>
  25. */
  26. @PersistenceCapable(detachable = "true")
  27. public class HasOneToManySetJDO implements HasOneToManyJDO {
  28. @PrimaryKey
  29. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  30. @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value="true")
  31. private String id;
  32. @Persistent
  33. private String val;
  34. public String getId() {
  35. return id;
  36. }
  37. @Persistent(mappedBy = "parent")
  38. @Element(dependent = "true")
  39. private Set<BidirectionalChildSetJDO> bidirChildren = new HashSet<BidirectionalChildSetJDO>();
  40. @Element(dependent = "true")
  41. private Set<Flight> flights = new HashSet<Flight>();
  42. @Element(dependent = "true")
  43. private Set<HasKeyPkJDO> hasKeyPks = new HashSet<HasKeyPkJDO>();
  44. public Set<BidirectionalChildJDO> getBidirChildren() {
  45. return new HashSet<BidirectionalChildJDO>(bidirChildren);
  46. }
  47. public void addBidirChild(BidirectionalChildJDO bidirChild) {
  48. bidirChildren.add((BidirectionalChildSetJDO) bidirChild);
  49. }
  50. public Set<Flight> getFlights() {
  51. if (flights == null) {
  52. flights = new HashSet<Flight>();
  53. }
  54. return flights;
  55. }
  56. public void addFlight(Flight flight) {
  57. this.flights.add(flight);
  58. }
  59. public Set<HasKeyPkJDO> getHasKeyPks() {
  60. if (hasKeyPks == null) {
  61. hasKeyPks = new HashSet<HasKeyPkJDO>();
  62. }
  63. return hasKeyPks;
  64. }
  65. public void addHasKeyPk(HasKeyPkJDO hasKeyPk) {
  66. this.hasKeyPks.add(hasKeyPk);
  67. }
  68. public String getVal() {
  69. return val;
  70. }
  71. public void setVal(String val) {
  72. this.val = val;
  73. }
  74. public void nullBidirChildren() {
  75. bidirChildren = null;
  76. }
  77. public void nullFlights() {
  78. flights = null;
  79. }
  80. public void nullHasKeyPks() {
  81. hasKeyPks = null;
  82. }
  83. public void clearBidirChildren() {
  84. bidirChildren.clear();
  85. }
  86. public void clearFlights() {
  87. flights.clear();
  88. }
  89. public void clearHasKeyPks() {
  90. hasKeyPks.clear();
  91. }
  92. public void addBidirChildAtPosition(BidirectionalChildJDO bidir, int pos) {
  93. throw new UnsupportedOperationException();
  94. }
  95. public void addFlightAtPosition(Flight f, int pos) {
  96. throw new UnsupportedOperationException();
  97. }
  98. public void addHasKeyPkAtPosition(HasKeyPkJDO hasKeyPk, int pos) {
  99. throw new UnsupportedOperationException();
  100. }
  101. public void removeBidirChildAtPosition(int i) {
  102. throw new UnsupportedOperationException();
  103. }
  104. public void removeFlightAtPosition(int i) {
  105. throw new UnsupportedOperationException();
  106. }
  107. public void removeHasKeyPkAtPosition(int i) {
  108. throw new UnsupportedOperationException();
  109. }
  110. public void addAtPosition(int i, BidirectionalChildJDO bidir) {
  111. throw new UnsupportedOperationException();
  112. }
  113. public void addAtPosition(int i, Flight f) {
  114. throw new UnsupportedOperationException();
  115. }
  116. public void addAtPosition(int i, HasKeyPkJDO hasKeyPk) {
  117. throw new UnsupportedOperationException();
  118. }
  119. public void removeFlights(Collection<Flight> flights) {
  120. this.flights.removeAll(flights);
  121. }
  122. public void removeBidirChildren(Collection<BidirectionalChildJDO> bidirChildren) {
  123. this.bidirChildren.removeAll(bidirChildren);
  124. }
  125. public void setBidirChildren(Collection<BidirectionalChildJDO> childList) {
  126. this.bidirChildren = (Set) childList;
  127. }
  128. }