PageRenderTime 38ms CodeModel.GetById 12ms app.highlight 20ms RepoModel.GetById 2ms app.codeStats 0ms

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