PageRenderTime 28ms CodeModel.GetById 19ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 77 lines | 44 code | 15 blank | 18 comment | 0 complexity | c8906bbf5d7c8f5623fc9f4d7496a024 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.HashSet;
22import java.util.Set;
23
24import javax.jdo.annotations.Element;
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 HasOneToManyUnencodedStringPkSetJDO implements HasOneToManyUnencodedStringPkJDO {
34
35  @PrimaryKey
36  private String key;
37
38  @Element(dependent = "true")
39  private Set<Flight> flights = Utils.newHashSet();
40
41  @Persistent(mappedBy = "parent")
42  @Element(dependent = "true")
43  private Set<BidirectionalChildUnencodedStringPkSetJDO> bidirChildren =
44      new HashSet<BidirectionalChildUnencodedStringPkSetJDO>();
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 String getId() {
55    return key;
56  }
57
58  public void setId(String key) {
59    this.key = key;
60  }
61
62  public void addBidirChild(BidirectionalChildUnencodedStringPkJDO child) {
63    bidirChildren.add((BidirectionalChildUnencodedStringPkSetJDO) child);
64  }
65
66  public Collection<BidirectionalChildUnencodedStringPkJDO> getBidirChildren() {
67    return (Set) bidirChildren;
68  }
69
70  public boolean removeFlights(Collection<Flight> flights) {
71    return this.flights.removeAll(flights);
72  }
73
74  public boolean removeBidirChildren(Collection<BidirectionalChildUnencodedStringPkJDO> bidirChildren) {
75    return this.bidirChildren.removeAll(bidirChildren);
76  }
77}