Fixed checkstyle, formatting, and sorting errors. rjrjr contributed a build file.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7675 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/bikeshed/build.xml b/bikeshed/build.xml
new file mode 100644
index 0000000..eba1c0f
--- /dev/null
+++ b/bikeshed/build.xml
@@ -0,0 +1,19 @@
+<project name="user" default="build" basedir=".">
+ <property name="gwt.root" location=".." />
+ <property name="project.tail" value="bikeshed" />
+ <property name="test.args" value="" />
+
+ <import file="${gwt.root}/common.ant.xml" />
+
+ <target name="checkstyle" description="Static analysis of source">
+ <gwt.checkstyle>
+ <fileset dir="src" />
+ </gwt.checkstyle>
+ <gwt.checkstyle.tests>
+ <fileset dir="test">
+ <include name="com/google/**/*.java" />
+ <include name="test/**" />
+ </fileset>
+ </gwt.checkstyle.tests>
+ </target>
+</project>
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/Callback.java b/bikeshed/src/com/google/gwt/requestfactory/shared/Callback.java
deleted file mode 100644
index 83f72cd..0000000
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/Callback.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.requestfactory.shared;
-
-public interface Callback<T> {
-
-}
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/Entity.java b/bikeshed/src/com/google/gwt/requestfactory/shared/Entity.java
index cc239ef..629132f 100644
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/Entity.java
+++ b/bikeshed/src/com/google/gwt/requestfactory/shared/Entity.java
@@ -17,6 +17,11 @@
import com.google.gwt.valuestore.shared.Property;
+/**
+ * Client side proxy object for server side entity.
+ *
+ * @param <E>
+ */
public interface Entity<E extends Entity<E>> {
Object getId();
Comparable<?> getVersion();
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequest.java b/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequest.java
index bef69d9..19ead9c 100644
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequest.java
+++ b/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequest.java
@@ -19,10 +19,16 @@
import com.google.gwt.valuestore.shared.Property;
import com.google.gwt.valuestore.shared.Values;
+/**
+ * Implemented by RequestObjects for service methods that return list
+ * properties.
+ *
+ * @param <E>
+ */
public interface EntityListRequest<E> {
- EntityListRequest<E> forProperty(Property<E, ?> property);
-
- EntityListRequest<E> to(HasValueList<Values<E>> watcher);
-
void fire();
+
+ EntityListRequest<E> forProperty(Property<E, ?> property);
+
+ EntityListRequest<E> to(HasValueList<Values<E>> watcher);
}
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequestCallback.java b/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequestCallback.java
deleted file mode 100644
index ec7e791..0000000
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/EntityListRequestCallback.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.requestfactory.shared;
-
-import java.util.List;
-
-/**
- *
- */
-public interface EntityListRequestCallback<E> {
- void onSuccess(List<E> entities);
- void onFailure(Exception E);
-}
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/Request.java b/bikeshed/src/com/google/gwt/requestfactory/shared/Request.java
deleted file mode 100644
index 97e4292..0000000
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/Request.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.requestfactory.shared;
-
-import com.google.gwt.user.client.ui.HasValue;
-import com.google.gwt.valuestore.shared.Property;
-
-public interface Request<E> {
- void fire();
-
- Request<E> forProperty(Property<E, ?> property);
-
- <V> Request<E> subscribe(HasValue<V> subscriber, Property<E, V> property);
-}
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/ServerType.java b/bikeshed/src/com/google/gwt/requestfactory/shared/ServerType.java
deleted file mode 100644
index 9174c1b..0000000
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/ServerType.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.requestfactory.shared;
-
-
-public @interface ServerType {
-
- Class<?> value();
-
-}
diff --git a/bikeshed/src/com/google/gwt/requestfactory/shared/Slot.java b/bikeshed/src/com/google/gwt/requestfactory/shared/Slot.java
index 093029d..a727ed8 100644
--- a/bikeshed/src/com/google/gwt/requestfactory/shared/Slot.java
+++ b/bikeshed/src/com/google/gwt/requestfactory/shared/Slot.java
@@ -17,6 +17,12 @@
import com.google.gwt.valuestore.shared.Property;
+/**
+ * A pointer to a property value of an Entity.
+ *
+ * @param <E> Entity
+ * @param <V> Value
+ */
public class Slot<E extends Entity<E>, V> {
private final E entity;
private final Property<E, V> property;
@@ -28,12 +34,27 @@
this.property = property;
}
- E getEntity() {
- return entity;
- }
-
- Property<E, V> getProperty() {
- return property;
+ // cast is okay b/c of class comparison
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Slot<E, V> other = (Slot<E, V>) obj;
+ if (!entity.getId().equals(other.entity.getId())) {
+ return false;
+ }
+ if (!property.equals(other.property)) {
+ return false;
+ }
+ return true;
}
@Override
@@ -45,23 +66,11 @@
return result;
}
- // cast is okay b/c of class comparison
- @SuppressWarnings("unchecked")
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Slot<E, V> other = (Slot<E, V>) obj;
- if (!entity.getId().equals(other.entity.getId())) {
- return false;
- }
- if (!property.equals(other.property)) {
- return false;
- }
- return true;
+ E getEntity() {
+ return entity;
+ }
+
+ Property<E, V> getProperty() {
+ return property;
}
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/client/Expenses.java b/bikeshed/src/com/google/gwt/sample/expenses/client/Expenses.java
index aca09b2..60c8670 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/client/Expenses.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/client/Expenses.java
@@ -1,3 +1,18 @@
+/*
+ * 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.client;
import com.google.gwt.core.client.EntryPoint;
@@ -48,26 +63,26 @@
"/expenses/data");
builder.setCallback(new RequestCallback() {
+ public void onError(Request request, Throwable exception) {
+ shell.error.setInnerText(SERVER_ERROR);
+ }
+
public void onResponseReceived(Request request, Response response) {
if (200 == response.getStatusCode()) {
String text = response.getText();
JsArray<ValuesImpl<Employee>> valueArray = ValuesImpl.arrayFromJson(text);
shell.setValueList(valueArray);
} else {
- shell.error.setInnerText(SERVER_ERROR + " (" + response.getStatusText()
- + ")");
+ shell.error.setInnerText(SERVER_ERROR + " ("
+ + response.getStatusText() + ")");
}
}
-
- public void onError(Request request, Throwable exception) {
- shell.error.setInnerText(SERVER_ERROR);
- }
});
-
+
try {
builder.send();
} catch (RequestException e) {
- shell.error.setInnerText(SERVER_ERROR + " (" + e.getMessage() +")");
+ shell.error.setInnerText(SERVER_ERROR + " (" + e.getMessage() + ")");
}
}
};
@@ -94,10 +109,8 @@
}
};
- requestFactory.employeeRequest().findAllEmployees() //
- .forProperty(Employee.DISPLAY_NAME) //
- .forProperty(Employee.USER_NAME) //
- .to(employees).fire();
+ requestFactory.employeeRequest().findAllEmployees().forProperty(
+ Employee.DISPLAY_NAME).forProperty(Employee.USER_NAME).to(employees).fire();
// TODO(rjrjr) now get details
final TextBox nameHolder = new TextBox();
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/client/Shell.java b/bikeshed/src/com/google/gwt/sample/expenses/client/Shell.java
index fcb2348..a195f4c 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/client/Shell.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/client/Shell.java
@@ -38,6 +38,9 @@
import java.util.List;
+/**
+ * UI shell for expenses sample app.
+ */
public class Shell extends Composite implements HasValueList<Values<Employee>> {
interface ShellUiBinder extends UiBinder<Widget, Shell> {
@@ -73,35 +76,6 @@
this.refresh = refresh;
}
- public void setValueList(List<Values<Employee>> newValues) {
- throw new UnsupportedOperationException();
- }
-
- public void setValueListSize(int size, boolean exact) {
- throw new UnsupportedOperationException();
- }
-
- @UiHandler("refreshButton")
- void onRefreshClick(@SuppressWarnings("unused") ClickEvent event) {
- if (refresh != null) {
- refresh.execute();
- }
- }
-
- /**
- * @param r
- * @param tableRows
- * @param valueRow
- */
- private void reuseRow(int r, NodeList<TableRowElement> tableRows,
- Values<Employee> valueRow) {
- TableRowElement tableRow = tableRows.getItem(r);
- NodeList<TableCellElement> tableCells = tableRow.getCells();
-
- tableCells.getItem(0).setInnerText(valueRow.get(Employee.USER_NAME));
- tableCells.getItem(0).setInnerText(valueRow.get(Employee.DISPLAY_NAME));
- }
-
/**
* @param valueArray
*/
@@ -131,4 +105,33 @@
table.removeChild(tableRows.getItem(r));
}
}
+
+ public void setValueList(List<Values<Employee>> newValues) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setValueListSize(int size, boolean exact) {
+ throw new UnsupportedOperationException();
+ }
+
+ @UiHandler("refreshButton")
+ void onRefreshClick(@SuppressWarnings("unused") ClickEvent event) {
+ if (refresh != null) {
+ refresh.execute();
+ }
+ }
+
+ /**
+ * @param r
+ * @param tableRows
+ * @param valueRow
+ */
+ private void reuseRow(int r, NodeList<TableRowElement> tableRows,
+ Values<Employee> valueRow) {
+ TableRowElement tableRow = tableRows.getItem(r);
+ NodeList<TableCellElement> tableCells = tableRow.getCells();
+
+ tableCells.getItem(0).setInnerText(valueRow.get(Employee.USER_NAME));
+ tableCells.getItem(0).setInnerText(valueRow.get(Employee.DISPLAY_NAME));
+ }
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/client/ValuesImpl.java b/bikeshed/src/com/google/gwt/sample/expenses/client/ValuesImpl.java
index 74a591d..aa11b97 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/client/ValuesImpl.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/client/ValuesImpl.java
@@ -21,7 +21,8 @@
import com.google.gwt.valuestore.shared.Values;
/**
- * JSO implementation of {@link Values}
+ * JSO implementation of {@link Values}.
+ * @param <T> value type
*/
public final class ValuesImpl<T> extends JavaScriptObject implements Values<T> {
@@ -33,6 +34,9 @@
return eval(json);
}-*/;
+ protected ValuesImpl() {
+ }
+
public native <V, P extends Property<T, V>> V get(P property) /*-{
return this[property.@com.google.gwt.valuestore.shared.Property::getName()()];
}-*/;
@@ -40,12 +44,8 @@
public native T getPropertyHolder() /*-{
return this.propertyHolder;
}-*/;
-
+
public native void setPropertyHolder(T propertyHolder) /*-{
this.propertyHolder = propertyHolder;
}-*/;
-
- protected ValuesImpl() {
-
- }
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/domain/CreationVisitor.java b/bikeshed/src/com/google/gwt/sample/expenses/domain/CreationVisitor.java
index 4c0fdf3..ad7a0fc 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/domain/CreationVisitor.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/domain/CreationVisitor.java
@@ -17,9 +17,10 @@
/**
* Creates a new entity of the type of the receiver.
+ *
+ * @param <E> The type of entity to create.
*/
-@SuppressWarnings("unchecked")
-// We guarantee same type at runtime
+//We guarantee same type at runtime
public class CreationVisitor<E extends Entity> implements EntityVisitor<E> {
private final long id;
private final int version;
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/domain/Employee.java b/bikeshed/src/com/google/gwt/sample/expenses/domain/Employee.java
index e52bce2..e223ebf 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/domain/Employee.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/domain/Employee.java
@@ -18,6 +18,9 @@
import java.util.List;
// @javax.persistence.Entity
+/**
+ * The Employee domain object.
+ */
public class Employee implements Entity {
public static List<Employee> findAllEmployees() {
return Storage.INSTANCE.findAllEmployees();
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/domain/Entity.java b/bikeshed/src/com/google/gwt/sample/expenses/domain/Entity.java
index 746dc0a..0883d32 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/domain/Entity.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/domain/Entity.java
@@ -19,12 +19,12 @@
* Pale imitation on the stuff JPA entities get baked into them.
*/
interface Entity {
- Long getId();
-
- Integer getVersion();
-
/**
* Double dispatch mechanism to ease imitation of framework mechanisms.
*/
<T> T accept(EntityVisitor<T> visitor);
+
+ Long getId();
+
+ Integer getVersion();
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/domain/NullFieldFiller.java b/bikeshed/src/com/google/gwt/sample/expenses/domain/NullFieldFiller.java
index b16b5e5..91cc2a2 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/domain/NullFieldFiller.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/domain/NullFieldFiller.java
@@ -1,3 +1,18 @@
+/*
+ * 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.domain;
/**
@@ -45,8 +60,8 @@
public Void visit(Report report) {
Report sparse = ((Report) sparseEntity);
- if (sparse.getApproved_supervisor() == null) {
- sparse.setApproved_supervisor(report.getApproved_supervisor());
+ if (sparse.getApprovedSupervisor() == null) {
+ sparse.setApprovedSupervisor(report.getApprovedSupervisor());
}
if (sparse.getPurpose() == null) {
sparse.setPurpose(report.getPurpose());
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/domain/Report.java b/bikeshed/src/com/google/gwt/sample/expenses/domain/Report.java
index 9540b68..bf29abb 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/domain/Report.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/domain/Report.java
@@ -46,7 +46,7 @@
// @javax.persistence.ManyToOne(targetEntity =
// com.google.io.expenses.server.domain.Employee.class)
// @javax.persistence.JoinColumn
- private Employee approved_supervisor;
+ private Employee approvedSupervisor;
// @javax.persistence.OneToMany(cascade = javax.persistence.CascadeType.ALL,
// mappedBy = "report")
@@ -69,8 +69,8 @@
/**
* @return the approved_supervisor
*/
- public Employee getApproved_supervisor() {
- return approved_supervisor;
+ public Employee getApprovedSupervisor() {
+ return approvedSupervisor;
}
/**
@@ -118,8 +118,8 @@
/**
* @param approvedSupervisor the approved_supervisor to set
*/
- public void setApproved_supervisor(Employee approvedSupervisor) {
- approved_supervisor = approvedSupervisor;
+ public void setApprovedSupervisor(Employee approvedSupervisor) {
+ this.approvedSupervisor = approvedSupervisor;
}
/**
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/domain/Storage.java b/bikeshed/src/com/google/gwt/sample/expenses/domain/Storage.java
index 11ef96b..a5c1ad8 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/domain/Storage.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/domain/Storage.java
@@ -25,6 +25,17 @@
* frameworks do. For goodness sake don't imitate this for production code.
*/
class Storage {
+
+ static final Storage INSTANCE;
+ static {
+ INSTANCE = new Storage();
+ fill(INSTANCE);
+ }
+
+ public static <E extends Entity> E edit(E v1) {
+ return v1.accept(new CreationVisitor<E>(v1));
+ }
+
/**
* @param storage to fill with demo entities
*/
@@ -46,38 +57,13 @@
e2.setDisplayName("George H. Indigo");
e2.setSupervisor(e);
storage.persist(e2);
-}
+ }
private final Map<Long, Entity> soup = new HashMap<Long, Entity>();
private final Map<String, Long> employeeUserNameIndex = new HashMap<String, Long>();
private long serial = 0;
- static final Storage INSTANCE;
- static {
- INSTANCE = new Storage();
- fill(INSTANCE);
- }
-
- public static <E extends Entity> E edit(E v1) {
- return v1.accept(new CreationVisitor<E>(v1));
- }
-
- @SuppressWarnings("unchecked")
- // We make runtime checks that return type matches in type
- synchronized <E extends Entity> E get(final E entity) {
- Entity previous = soup.get(entity.getId());
- if (null == previous) {
- throw new IllegalArgumentException(String.format(
- "In %s, unknown id %d", entity, entity.getId()));
- }
- if (!previous.getClass().equals(entity.getClass())) {
- throw new IllegalArgumentException(String.format(
- "Type mismatch, fetched %s for %s", entity, previous));
- }
- return (E) previous;
- }
-
- synchronized public <E extends Entity> E persist(final E delta) {
+ public synchronized <E extends Entity> E persist(final E delta) {
E next = null;
E previous = null;
@@ -111,7 +97,7 @@
synchronized List<Employee> findAllEmployees() {
List<Employee> rtn = new ArrayList<Employee>();
for (Map.Entry<String, Long> entry : employeeUserNameIndex.entrySet()) {
- rtn.add((Employee)get(entry.getValue()));
+ rtn.add((Employee) get(entry.getValue()));
}
return rtn;
}
@@ -121,7 +107,22 @@
return (Employee) get(id);
}
- synchronized private Entity get(Long id) {
+ @SuppressWarnings("unchecked")
+ // We make runtime checks that return type matches in type
+ synchronized <E extends Entity> E get(final E entity) {
+ Entity previous = soup.get(entity.getId());
+ if (null == previous) {
+ throw new IllegalArgumentException(String.format("In %s, unknown id %d",
+ entity, entity.getId()));
+ }
+ if (!previous.getClass().equals(entity.getClass())) {
+ throw new IllegalArgumentException(String.format(
+ "Type mismatch, fetched %s for %s", entity, previous));
+ }
+ return (E) previous;
+ }
+
+ private synchronized Entity get(Long id) {
return soup.get(id);
}
@@ -132,7 +133,8 @@
}
public Void visit(Employee employee) {
- if (null == employee.getUserName()) return null;
+ if (null == employee.getUserName())
+ return null;
if (previous != null) {
Employee prevEmployee = (Employee) previous;
if (!prevEmployee.getUserName().equals(next)) {
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/shared/Employee.java b/bikeshed/src/com/google/gwt/sample/expenses/shared/Employee.java
index 49c3486..c2c24c4 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/shared/Employee.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/shared/Employee.java
@@ -16,27 +16,30 @@
package com.google.gwt.sample.expenses.shared;
import com.google.gwt.requestfactory.shared.Entity;
-import com.google.gwt.requestfactory.shared.ServerType;
import com.google.gwt.requestfactory.shared.Slot;
import com.google.gwt.valuestore.shared.Property;
-@ServerType(com.google.gwt.sample.expenses.domain.Employee.class)
+/**
+ * The employee proxy object, would be auto-generated.
+ *
+ */
public class Employee implements Entity<Employee> {
+ public static final Property<Employee, String> DISPLAY_NAME = new Property<Employee, String>(
+ Employee.class, String.class, "DISPLAY_NAME");
+ public static final Property<Employee, Employee> SUPERVISOR = new Property<Employee, Employee>(
+ Employee.class, Employee.class, "SUPERVISOR");
+
+ public static final Property<Employee, String> USER_NAME = new Property<Employee, String>(
+ Employee.class, String.class, "USER_NAME");
+
private final String id;
private final Integer version;
-
+
Employee(String id, Integer version) {
this.id = id;
this.version = version;
}
-
- public static final Property<Employee, String> USER_NAME = new Property<Employee, String>(
- Employee.class, String.class, "USER_NAME");
- public static final Property<Employee, String> DISPLAY_NAME = new Property<Employee, String>(
- Employee.class, String.class, "DISPLAY_NAME");
- public static final Property<Employee, Employee> SUPERVISOR = new Property<Employee, Employee>(
- Employee.class, Employee.class, "SUPERVISOR");
public String getId() {
return id;
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeRequests.java b/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeRequests.java
index 60741ea..b9e2d8a 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeRequests.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/shared/EmployeeRequests.java
@@ -27,6 +27,9 @@
import java.util.Map;
import java.util.Set;
+/**
+ * "Generated" from static methods of {@link com.google.gwt.sample.expenses.domain.Employee}
+ */
public class EmployeeRequests {
private final ValueStore values;
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpenseRequestFactory.java b/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpenseRequestFactory.java
index ff780d7..8760dbf 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpenseRequestFactory.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/shared/ExpenseRequestFactory.java
@@ -36,7 +36,6 @@
public void addValidation() {
// TODO Auto-generated method stub
-
}
public DeltaValueStore edit() {
@@ -46,25 +45,15 @@
public <T, V> void subscribe(HasValue<V> watcher, T propertyOwner,
Property<T, V> property) {
// TODO Auto-generated method stub
-
}
public <T, V> void subscribe(HasValueList<Values<T>> watcher,
T propertyOwner, Set<Property<T, ?>> properties) {
- // TODO Auto-generated method stub
-
+ // TODO Auto-generated method stub
}
};
- public ValueStore getValueStore() {
- return values;
- }
-
- public DeltaValueStore newDeltaStore() {
- return values.edit();
- }
-
public EmployeeRequests employeeRequest() {
return new EmployeeRequests(values);
}
@@ -72,4 +61,12 @@
public EmployeeRequests employeeRequest(DeltaValueStore deltas) {
return new EmployeeRequests(deltas);
}
+
+ public ValueStore getValueStore() {
+ return values;
+ }
+
+ public DeltaValueStore newDeltaStore() {
+ return values.edit();
+ }
}
diff --git a/bikeshed/src/com/google/gwt/user/client/ui/HasValueList.java b/bikeshed/src/com/google/gwt/user/client/ui/HasValueList.java
index 75484d7..e24e318 100644
--- a/bikeshed/src/com/google/gwt/user/client/ui/HasValueList.java
+++ b/bikeshed/src/com/google/gwt/user/client/ui/HasValueList.java
@@ -21,6 +21,8 @@
* Alternative to ListHandler that stays away from complexities of event
* handling, better parallel to {@link HasValue} being a passive receiver of
* data changes.
+ *
+ * @param <V> value type
*/
public interface HasValueList<V> {
void editValueList(boolean replace, int index, List<V> newValues);
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java b/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java
index d6aa47b..5072c0a 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java
@@ -18,18 +18,21 @@
import java.util.Collection;
import java.util.List;
+/**
+ * Set of changes to a ValueStore.
+ */
public interface DeltaValueStore extends ValueStore {
- <T, V> void setValue(T type, Property<T, V> property, V value);
-
<T, V> void editList(T entity, Property<T, List<V>> property,
boolean replace, int index, Collection<V> newValues);
+ boolean isChanged();
+
+ <T, V> void setValue(T type, Property<T, V> property, V value);
+
/**
* Returns true if all validations have passed. May notify subscribers that
* implement {@com.google.gwt.user.client.ui.HasErrors} of new validation
* errors.
*/
boolean validate();
-
- boolean isChanged();
}
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/Path.java b/bikeshed/src/com/google/gwt/valuestore/shared/Path.java
index 49d802f..44460e6 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/Path.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/Path.java
@@ -17,6 +17,12 @@
import java.util.List;
+/**
+ * A path of entity properties.
+ *
+ * @param <T>
+ * @param <V>
+ */
public class Path<T, V> {
List<Property<?,?>> getProperties() {
return null;
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/Property.java b/bikeshed/src/com/google/gwt/valuestore/shared/Property.java
index 4910dec..4d55da0 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/Property.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/Property.java
@@ -15,7 +15,12 @@
*/
package com.google.gwt.valuestore.shared;
-
+/**
+ * Represents a property of a type managed by {@link ValueStore}.
+ *
+ * @param <T>
+ * @param <V>
+ */
public class Property<T, V> {
private final Class<T> propertyHolderType;
private final Class<V> valueType;
@@ -35,16 +40,16 @@
}
/**
- * @return the valueClass
- */
- public Class<V> getValueType() {
- return valueType;
- }
-
- /**
* @return the name
*/
public String getName() {
return name;
}
+
+ /**
+ * @return the valueClass
+ */
+ public Class<V> getValueType() {
+ return valueType;
+ }
}
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/ValueStore.java b/bikeshed/src/com/google/gwt/valuestore/shared/ValueStore.java
index 34b859f..45bca44 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/ValueStore.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/ValueStore.java
@@ -20,6 +20,10 @@
import java.util.Set;
+/**
+ * A store of property values. Allows interested parties to subscribe to changes
+ * to particular sets of values.
+ */
public interface ValueStore {
/**
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/Values.java b/bikeshed/src/com/google/gwt/valuestore/shared/Values.java
index c8b4def..82c8bcb 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/Values.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/Values.java
@@ -15,12 +15,13 @@
*/
package com.google.gwt.valuestore.shared;
-
/**
- * Provides access to the values of an entity.
+ * Provides access to the values of an object managed by the {@link ValueStore}.
+ *
+ * @param <T> value type.
*/
public interface Values<T> {
T getPropertyHolder();
-
+
<V, P extends Property<T, V>> V get(P property);
}
diff --git a/bikeshed/test/com/google/gwt/sample/expenses/domain/NullFieldFillerTest.java b/bikeshed/test/com/google/gwt/sample/expenses/domain/NullFieldFillerTest.java
index 2000468..d40cf64 100644
--- a/bikeshed/test/com/google/gwt/sample/expenses/domain/NullFieldFillerTest.java
+++ b/bikeshed/test/com/google/gwt/sample/expenses/domain/NullFieldFillerTest.java
@@ -53,14 +53,14 @@
public Void visit(Report report) {
Report full = new Report(1L, 2);
- full.setApproved_supervisor(tester.employee);
+ full.setApprovedSupervisor(tester.employee);
full.setPurpose("purpose");
full.setReporter(tester.employee);
full.setStatus(Status.Paid);
doFillAndVerify(report, full);
- assertSame(tester.employee, report.getApproved_supervisor());
+ assertSame(tester.employee, report.getApprovedSupervisor());
assertEquals("purpose", report.getPurpose());
assertSame(tester.employee, report.getReporter());
assertEquals(Status.Paid, report.getStatus());
diff --git a/bikeshed/test/com/google/gwt/sample/expenses/domain/StorageTest.java b/bikeshed/test/com/google/gwt/sample/expenses/domain/StorageTest.java
index 5a3a18b..ab744b7 100644
--- a/bikeshed/test/com/google/gwt/sample/expenses/domain/StorageTest.java
+++ b/bikeshed/test/com/google/gwt/sample/expenses/domain/StorageTest.java
@@ -66,6 +66,13 @@
});
}
+ private void doTestEdit(Entity v1) {
+ Entity delta = Storage.edit(v1);
+ Entity v2 = store.persist(delta);
+ assertEquals(Integer.valueOf(v1.getVersion() + 1), v2.getVersion());
+ assertSame(v2, store.get(Storage.edit(v2)));
+ }
+
private Entity doTestNew(Entity e) {
Entity v1 = store.persist(e);
assertEquals(Integer.valueOf(0), v1.getVersion());
@@ -73,11 +80,4 @@
assertSame(v1, store.get(Storage.edit(v1)));
return v1;
}
-
- private void doTestEdit(Entity v1) {
- Entity delta = Storage.edit(v1);
- Entity v2 = store.persist(delta);
- assertEquals(Integer.valueOf(v1.getVersion() + 1), v2.getVersion());
- assertSame(v2, store.get(Storage.edit(v2)));
- }
}