/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
- /**********************************************************************
- Copyright (c) 2009 Google Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- **********************************************************************/
- package com.google.appengine.datanucleus.test;
-
- import com.google.appengine.datanucleus.Utils;
-
- import java.util.Collection;
- import java.util.HashSet;
- import java.util.Set;
-
- import javax.jdo.annotations.Element;
- import javax.jdo.annotations.PersistenceCapable;
- import javax.jdo.annotations.Persistent;
- import javax.jdo.annotations.PrimaryKey;
-
- /**
- * @author Max Ross <maxr@google.com>
- */
- @PersistenceCapable(detachable = "true")
- public class HasOneToManyUnencodedStringPkSetJDO implements HasOneToManyUnencodedStringPkJDO {
-
- @PrimaryKey
- private String key;
-
- @Element(dependent = "true")
- private Set<Flight> flights = Utils.newHashSet();
-
- @Persistent(mappedBy = "parent")
- @Element(dependent = "true")
- private Set<BidirectionalChildUnencodedStringPkSetJDO> bidirChildren =
- new HashSet<BidirectionalChildUnencodedStringPkSetJDO>();
-
- public void addFlight(Flight flight) {
- flights.add(flight);
- }
-
- public Collection<Flight> getFlights() {
- return flights;
- }
-
- public String getId() {
- return key;
- }
-
- public void setId(String key) {
- this.key = key;
- }
-
- public void addBidirChild(BidirectionalChildUnencodedStringPkJDO child) {
- bidirChildren.add((BidirectionalChildUnencodedStringPkSetJDO) child);
- }
-
- public Collection<BidirectionalChildUnencodedStringPkJDO> getBidirChildren() {
- return (Set) bidirChildren;
- }
-
- public boolean removeFlights(Collection<Flight> flights) {
- return this.flights.removeAll(flights);
- }
-
- public boolean removeBidirChildren(Collection<BidirectionalChildUnencodedStringPkJDO> bidirChildren) {
- return this.bidirChildren.removeAll(bidirChildren);
- }
- }