PageRenderTime 15ms CodeModel.GetById 3ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

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