blob: 39965b42e36a18919dc61c6dbf2690a444267311 [file] [log] [blame]
/*
* Copyright 2010 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.gwt.sample.expenses.shared;
import com.google.gwt.requestfactory.shared.Id;
import com.google.gwt.requestfactory.shared.LongString;
import com.google.gwt.requestfactory.shared.Version;
import com.google.gwt.valuestore.shared.PrimitiveProperty;
import com.google.gwt.valuestore.shared.Property;
import com.google.gwt.valuestore.shared.Values;
import com.google.gwt.valuestore.shared.ValuesChangedEvent;
import com.google.gwt.valuestore.shared.impl.PrimitivePropertyImpl;
import com.google.gwt.valuestore.shared.impl.PropertyImpl;
import java.util.HashSet;
import java.util.Set;
/**
* "API Generated" key for proxy {@link com.google.gwt.valuestore.shared.Values
* Values} of {@link com.google.gwt.sample.expenses.server.domain.Employee
* domain.Employee}.
* <p>
* IRL this class will be generated by a JPA-savvy tool run before compilation.
*/
public class EmployeeKey implements ExpensesEntityKey<EmployeeKey> {
private static EmployeeKey instance;
public static EmployeeKey get() {
if (instance == null) {
instance = new EmployeeKey();
}
return instance;
}
private final PrimitivePropertyImpl<EmployeeKey, String> id = new PrimitivePropertyImpl<EmployeeKey, String>(
String.class, "id");
private final PrimitivePropertyImpl<EmployeeKey, String> displayName = new PrimitivePropertyImpl<EmployeeKey, String>(
String.class, "displayName");
private final PropertyImpl<EmployeeKey, EmployeeKey> supervisor = new PropertyImpl<EmployeeKey, EmployeeKey>(
"supervisor");
private final PrimitivePropertyImpl<EmployeeKey, String> userName = new PrimitivePropertyImpl<EmployeeKey, String>(
String.class, "userName");
private final PrimitivePropertyImpl<EmployeeKey, Integer> version = new PrimitivePropertyImpl<EmployeeKey, Integer>(
Integer.class, "version");
private final Set<PropertyImpl<EmployeeKey, ?>> properties = new HashSet<PropertyImpl<EmployeeKey, ?>>();
EmployeeKey() {
properties.add(id);
properties.add(displayName);
properties.add(supervisor);
properties.add(userName);
properties.add(version);
for (PropertyImpl<EmployeeKey, ?> p : properties) {
p.setKey(this);
}
}
public <T> T accept(ExpensesEntityFilter<T> filter) {
return filter.filter(this);
}
public void accept(ExpensesEntityVisitor visitor) {
visitor.visit(this);
}
public Set<? extends Property<EmployeeKey, ?>> all() {
return properties;
}
public ValuesChangedEvent<EmployeeKey, ?> createChangeEvent(
Values<EmployeeKey> values) {
return new EmployeeChanged(values);
}
public PrimitiveProperty<EmployeeKey, String> getDisplayName() {
return displayName;
}
@LongString
@Id
public PrimitiveProperty<EmployeeKey, String> getId() {
return id;
}
public Property<EmployeeKey, EmployeeKey> getSupervisor() {
return supervisor;
}
public PrimitiveProperty<EmployeeKey, String> getUserName() {
return userName;
}
@Version
public PrimitiveProperty<EmployeeKey, Integer> getVersion() {
return version;
}
}