PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://datanucleus-appengine.googlecode.com/
Java | 80 lines | 46 code | 16 blank | 18 comment | 0 complexity | ffd262993cfe902aaec72cf9be2c758c 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.ArrayList;
21import java.util.Collection;
22import java.util.List;
23
24import javax.jdo.annotations.Element;
25import javax.jdo.annotations.Order;
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 HasOneToManyUnencodedStringPkListJDO implements HasOneToManyUnencodedStringPkJDO {
35
36  @PrimaryKey
37  private String key;
38
39  @Element(dependent = "true")
40  @Order(column = "flights_INTEGER_IDX_unencodedstringpk")
41  private List<Flight> flights = Utils.newArrayList();
42
43  @Persistent(mappedBy = "parent")
44  @Element(dependent = "true")
45  private List<BidirectionalChildUnencodedStringPkListJDO> bidirChildren =
46      new ArrayList<BidirectionalChildUnencodedStringPkListJDO>();
47
48  public void addFlight(Flight flight) {
49    flights.add(flight);
50  }
51
52  public Collection<Flight> getFlights() {
53    return flights;
54  }
55
56  public String getId() {
57    return key;
58  }
59
60  public void setId(String key) {
61    this.key = key;
62  }
63
64  public void addBidirChild(BidirectionalChildUnencodedStringPkJDO child) {
65    bidirChildren.add((BidirectionalChildUnencodedStringPkListJDO) child);
66  }
67
68  public Collection<BidirectionalChildUnencodedStringPkJDO> getBidirChildren() {
69    return (List) bidirChildren;
70  }
71
72  public boolean removeFlights(Collection<Flight> flights) {
73    return this.flights.removeAll(flights);
74  }
75
76  public boolean removeBidirChildren(Collection<BidirectionalChildUnencodedStringPkJDO> bidirChildren) {
77    return this.bidirChildren.removeAll(bidirChildren);
78  }
79
80}