PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 73 lines | 41 code | 14 blank | 18 comment | 0 complexity | 5c2244df4b7202240d12c06916084580 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 com.google.appengine.datanucleus.Utils;
19
20import java.util.Collection;
21import java.util.Set;
22
23import javax.jdo.annotations.Element;
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 HasOneToManyLongPkSetJDO implements HasOneToManyLongPkJDO {
34
35  @PrimaryKey
36  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
37  private Long key;
38
39  @Element(dependent = "true")
40  private Set<Flight> flights = Utils.newHashSet();
41
42  @Persistent(mappedBy = "parent")
43  @Element(dependent = "true")
44  private Set<BidirectionalChildLongPkSetJDO> bidirChildren = Utils.newHashSet();
45
46  public void addFlight(Flight flight) {
47    flights.add(flight);
48  }
49
50  public Collection<Flight> getFlights() {
51    return flights;
52  }
53
54  public Long getId() {
55    return key;
56  }
57
58  public void addBidirChild(BidirectionalChildLongPkJDO child) {
59    bidirChildren.add((BidirectionalChildLongPkSetJDO) child);
60  }
61
62  public Collection<BidirectionalChildLongPkJDO> getBidirChildren() {
63    return (Set) bidirChildren;
64  }
65
66  public void removeFlights(Collection<Flight> flights) {
67    this.flights.removeAll(flights);
68  }
69
70  public void removeBidirChildren(Collection<BidirectionalChildLongPkJDO> bidirChildren) {
71    this.bidirChildren.removeAll(bidirChildren);
72  }
73}