PageRenderTime 42ms CodeModel.GetById 12ms app.highlight 23ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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.util.ArrayList;
 19import java.util.Collection;
 20import java.util.List;
 21
 22import javax.jdo.annotations.Element;
 23import javax.jdo.annotations.PersistenceCapable;
 24import javax.jdo.annotations.Persistent;
 25import javax.jdo.annotations.PrimaryKey;
 26
 27/**
 28 * @author Max Ross <maxr@google.com>
 29 */
 30@PersistenceCapable(detachable = "true")
 31public class HasOneToManyStringPkListJDO {
 32
 33  @PrimaryKey
 34  private String id;
 35
 36  @Persistent
 37  private String val;
 38
 39  public String getId() {
 40    return id;
 41  }
 42
 43  public void setId(String id) {
 44    this.id = id;
 45  }
 46
 47  @Persistent(mappedBy = "parent")
 48  @Element(dependent = "true")
 49  private List<BidirectionalChildStringPkListJDO> bidirChildren = new ArrayList<BidirectionalChildStringPkListJDO>();
 50
 51  @Element(dependent = "true")
 52  private List<Flight> flights = new ArrayList<Flight>();
 53
 54  @Element(dependent = "true")
 55  private List<HasKeyPkJDO> hasKeyPks = new ArrayList<HasKeyPkJDO>();
 56
 57  public List<BidirectionalChildJDO> getBidirChildren() {
 58    return (List) bidirChildren;
 59  }
 60
 61  public void addBidirChild(BidirectionalChildStringPkListJDO bidirChild) {
 62    bidirChildren.add(bidirChild);
 63  }
 64
 65  public List<Flight> getFlights() {
 66    return flights;
 67  }
 68
 69  public void addFlight(Flight flight) {
 70    this.flights.add(flight);
 71  }
 72
 73  public List<HasKeyPkJDO> getHasKeyPks() {
 74    return hasKeyPks;
 75  }
 76
 77  public void addHasKeyPk(HasKeyPkJDO hasKeyPk) {
 78    this.hasKeyPks.add(hasKeyPk);
 79  }
 80
 81  public String getVal() {
 82    return val;
 83  }
 84
 85  public void setVal(String val) {
 86    this.val = val;
 87  }
 88
 89  public void nullBidirChildren() {
 90    bidirChildren = null;
 91  }
 92
 93  public void nullFlights() {
 94    flights = null;
 95  }
 96
 97  public void nullHasKeyPks() {
 98    hasKeyPks = null;
 99  }
100
101  public void clearBidirChildren() {
102    bidirChildren.clear();
103  }
104
105  public void clearFlights() {
106    flights.clear();
107  }
108
109  public void clearHasKeyPks() {
110    hasKeyPks.clear();
111  }
112
113  public void addBidirChildAtPosition(BidirectionalChildStringPkListJDO bidir, int pos) {
114    bidirChildren.set(pos, bidir);
115  }
116
117  public void addFlightAtPosition(Flight f, int pos) {
118    flights.set(pos, f);
119  }
120
121  public void addHasKeyPkAtPosition(HasKeyPkJDO hasKeyPk, int pos) {
122    hasKeyPks.set(pos, hasKeyPk);
123  }
124
125  public void removeBidirChildAtPosition(int i) {
126    bidirChildren.remove(i);
127  }
128
129  public void removeFlightAtPosition(int i) {
130    flights.remove(i);
131  }
132
133  public void removeHasKeyPkAtPosition(int i) {
134    hasKeyPks.remove(i);
135  }
136
137  public void addAtPosition(int i, BidirectionalChildStringPkListJDO bidir) {
138    bidirChildren.add(i, bidir);
139  }
140
141  public void addAtPosition(int i, Flight f) {
142    flights.add(i, f);
143  }
144
145  public void addAtPosition(int i, HasKeyPkJDO hasKeyPk) {
146    hasKeyPks.add(i, hasKeyPk);
147  }
148
149  public void removeFlights(Collection<Flight> flights) {
150    this.flights.removeAll(flights);
151  }
152
153  public void removeBidirChildren(Collection<BidirectionalChildJDO> bidirChildren) {
154    this.bidirChildren.removeAll(bidirChildren);
155  }
156}