/* Copyright 2010 John L. Reilly
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.riq.nonpersist;
import java.util.List;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
import com.riq.entity.Department;
import com.riq.entity.Member;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ReportDept implements Comparable<ReportDept> {
private static final long serialVersionUID = 1L;
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@NotPersistent
private final String deptType;
@NotPersistent
private final Department dept;
@NotPersistent
private final List<String> locTypes;
@NotPersistent
private List<ReportLocation> locations;
@NotPersistent
private final List<String> memTypes;
@NotPersistent
private List<Member> unassignedMembers;
@NotPersistent
private List<Member> activeMembers;
@NotPersistent
private List<Member> inactiveMembers;
/**
* This is the default constructor for this class
* @param deptType Cannot be null.
* @param dept
* @param locTypes
* @param locations
* @param unassignedMembers
* @param activeMembers
* @param inactiveMembers
*/
public ReportDept(
String deptType,
Department dept,
List<String> locTypes,
List<ReportLocation> locations,
List<String> memTypes,
List<Member> unassignedMembers,
List<Member> activeMembers,
List<Member> inactiveMembers
) {
if (dept == null )
throw new IllegalArgumentException("dept cannot be null");
this.deptType = deptType;
this.dept = dept;
this.locTypes = locTypes;
this.locations = locations;
this.memTypes = memTypes;
this.unassignedMembers = unassignedMembers;
this.activeMembers = activeMembers;
this.inactiveMembers = inactiveMembers;
}
public String deptType() { return deptType; }
public Department dept() { return dept; }
public List<String> locTypes() { return locTypes; }
public List<ReportLocation> locations() { return locations; }
public List<String> memTypes() { return memTypes; }
public List<Member> unassignedMembers() { return unassignedMembers; }
public List<Member> activeMembers() { return activeMembers; }
public List<Member> inactiveMembers() { return inactiveMembers; }
public boolean equals(Object o) {
if (!(o instanceof ReportLocation))
return false;
ReportDept t = (ReportDept)o;
return t.deptType.equals(deptType) &&
t.dept.equals(dept) &&
t.locTypes.equals(locTypes) &&
t.locations.equals(locations) &&
t.memTypes.equals(memTypes) &&
t.unassignedMembers.equals(unassignedMembers) &&
t.activeMembers.equals(activeMembers) &&
t.inactiveMembers.equals(inactiveMembers);
}
private String sortingKey() {
return deptType;
}
public int compareTo(ReportDept t) {
return sortingKey().compareTo(t.sortingKey());
}
}
|