You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(12) |
Nov
(2) |
Dec
(15) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(7) |
Feb
(2) |
Mar
|
Apr
(22) |
May
|
Jun
|
Jul
(1) |
Aug
(29) |
Sep
(17) |
Oct
(4) |
Nov
|
Dec
(19) |
| 2010 |
Jan
|
Feb
(9) |
Mar
(2) |
Apr
(34) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(25) |
Nov
(22) |
Dec
(3) |
| 2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <iro...@us...> - 2009-01-20 00:34:11
|
Revision: 89
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=89&view=rev
Author: iroberts
Date: 2009-01-20 00:34:08 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
match toString style
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java 2009-01-20 00:17:06 UTC (rev 88)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java 2009-01-20 00:34:08 UTC (rev 89)
@@ -40,7 +40,7 @@
@Override
public String toString() {
//TODO - can we do better here?
- return propertyName + ": " + lhs + " versus " + rhs;
+ return propertyName + ": {" + lhs + "} versus {" + rhs + "}";
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2009-01-20 00:17:17
|
Revision: 88
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=88&view=rev
Author: iroberts
Date: 2009-01-20 00:17:06 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
Implement difference calculation.
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java
trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java
trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java
trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
trunk/Pojomatic/src/test/java/org/pojomatic/internal/PojomatorImplTest.java
Added Paths:
-----------
trunk/Pojomatic/src/main/java/org/pojomatic/diff/DifferenceToNull.java
trunk/Pojomatic/src/main/java/org/pojomatic/diff/Differences.java
trunk/Pojomatic/src/main/java/org/pojomatic/diff/PropertyDifferences.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2009-01-05 22:33:48 UTC (rev 87)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -1,8 +1,6 @@
package org.pojomatic;
-import java.util.List;
-
-import org.pojomatic.diff.Difference;
+import org.pojomatic.diff.Differences;
import org.pojomatic.internal.PojomatorImpl;
import org.pojomatic.internal.SelfPopulatingMap;
@@ -103,7 +101,23 @@
return pojomator(getClass(pojo)).doEquals(pojo, other);
}
+
/**
+ * Compute the differences between {@code pojo} and {@code other} among the properties
+ * examined by {@link #equals(Object, Object)} for type {@code T}.
+ *
+ * @param <T> the static type of the first object to compare
+ * @param <S> the static type of the first object to compare
+ * @param instance the instance to diff against - must not be {@code null}
+ * @param other the instance to diff
+ * @return the list of differences (possibly empty) between {@code instance} and {@code other}
+ * among the properties examined by {@link #doEquals(Object, Object)} for type {@code T}.
+ */
+ public static <T, S extends T> Differences diff(T pojo, S other) {
+ return pojomator(getClass(pojo)).doDiff(pojo, other);
+ }
+
+ /**
* Get the {@code Pojomator} for {@code pojoClass}. The same instance will be returned every time
* for a given value of {@code pojoClass}.
* @param <T> the type represented by {@code pojoClass}
@@ -119,8 +133,4 @@
private static <T> Class<T> getClass(T pojo) {
return (Class<T>) pojo.getClass();
}
-
- public static <T, S extends T> List<Difference> diff(T lhs, S rhs) {
- return null; //TODO
- }
}
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java 2009-01-05 22:33:48 UTC (rev 87)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -1,9 +1,7 @@
package org.pojomatic;
-import java.util.List;
+import org.pojomatic.diff.Differences;
-import org.pojomatic.diff.Difference;
-
/**
* An automatically generated provider of the three standard {@code Object} methods,
* {@link Object#equals(Object)}, {@link Object#hashCode()} and {@link Object#toString()}.
@@ -44,12 +42,14 @@
/**
* Compute the differences between {@code instance} and {@code other} among the properties
- * examined by {@link #doEquals(Object, Object)}.
+ * examined by {@link #doEquals(Object, Object)}. It is guaranteed that invoking
+ * {@link Differences#areEqual()} on the returned object will return true iff
+ * {@code instance.equals(other)}.
*
* @param instance the instance to diff against - must not be {@code null}
* @param other the instance to diff
- * @return the list of differences (possibly empty) between {@code instance} and {@code other}
+ * @return the differences between {@code instance} and {@code other}
* among the properties examined by {@link #doEquals(Object, Object)}.
*/
- List<Difference> doDiff(T instance, T other);
+ Differences doDiff(T instance, T other);
}
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java 2009-01-05 22:33:48 UTC (rev 87)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -39,8 +39,8 @@
@Override
public String toString() {
- // TODO implement a sensible String representation
- return super.toString();
+ //TODO - can we do better here?
+ return propertyName + ": " + lhs + " versus " + rhs;
}
}
Added: trunk/Pojomatic/src/main/java/org/pojomatic/diff/DifferenceToNull.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/diff/DifferenceToNull.java (rev 0)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/diff/DifferenceToNull.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -0,0 +1,18 @@
+package org.pojomatic.diff;
+
+public class DifferenceToNull implements Differences {
+ private final Object instance;
+
+ public DifferenceToNull(Object instance) {
+ this.instance = instance;
+ }
+
+ @Override
+ public String toString() {
+ return "the object {" + instance + "} is different than null" ;
+ }
+
+ public boolean areEqual() {
+ return false;
+ }
+}
Property changes on: trunk/Pojomatic/src/main/java/org/pojomatic/diff/DifferenceToNull.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/Pojomatic/src/main/java/org/pojomatic/diff/Differences.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/diff/Differences.java (rev 0)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/diff/Differences.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -0,0 +1,18 @@
+package org.pojomatic.diff;
+
+/**
+ * A summary of differences (if any) between two POJOs.
+ */
+public interface Differences {
+ /**
+ * @return a description of the differences
+ */
+ @Override
+ String toString();
+
+ /**
+ * @return {@code true} if the two POJOs were {@code equal} to each other;
+ * {@code false} otherwise.
+ */
+ boolean areEqual();
+}
Property changes on: trunk/Pojomatic/src/main/java/org/pojomatic/diff/Differences.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/Pojomatic/src/main/java/org/pojomatic/diff/PropertyDifferences.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/diff/PropertyDifferences.java (rev 0)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/diff/PropertyDifferences.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -0,0 +1,28 @@
+package org.pojomatic.diff;
+
+import java.util.Collections;
+import java.util.List;
+
+public class PropertyDifferences implements Differences {
+ private final List<Difference> differences;
+
+ public PropertyDifferences(List<Difference> differences) {
+ if (differences == null) {
+ throw new NullPointerException("list of differences is null");
+ }
+ this.differences = Collections.unmodifiableList(differences);
+ }
+
+ public List<Difference> getDifferences() {
+ return differences;
+ }
+
+ @Override
+ public String toString() {
+ return differences.isEmpty() ? "no differences" : differences.toString();
+ }
+
+ public boolean areEqual() {
+ return differences.isEmpty();
+ }
+}
Property changes on: trunk/Pojomatic/src/main/java/org/pojomatic/diff/PropertyDifferences.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2009-01-05 22:33:48 UTC (rev 87)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -3,6 +3,7 @@
import java.lang.reflect.AnnotatedElement;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.pojomatic.Pojomator;
@@ -11,6 +12,9 @@
import org.pojomatic.annotations.PojomaticPolicy;
import org.pojomatic.annotations.PropertyFormat;
import org.pojomatic.diff.Difference;
+import org.pojomatic.diff.DifferenceToNull;
+import org.pojomatic.diff.Differences;
+import org.pojomatic.diff.PropertyDifferences;
import org.pojomatic.formatter.DefaultPojoFormatter;
import org.pojomatic.formatter.DefaultPropertyFormatter;
import org.pojomatic.formatter.PojoFormatter;
@@ -88,90 +92,9 @@
}
for (PropertyElement prop: classProperties.getEqualsProperties()) {
- Object instanceValue = prop.getValue(instance);
- Object otherValue = prop.getValue(other);
- if (instanceValue == null) {
- if (otherValue != null) {
- return false;
- }
+ if (!areValuesEqual(prop.getValue(instance), prop.getValue(other))) {
+ return false;
}
- else { // instanceValue is not null
- if (otherValue == null) {
- return false;
- }
- if (!instanceValue.getClass().isArray()) {
- if (!instanceValue.equals(otherValue)) {
- return false;
- }
- }
- else {
- if (!otherValue.getClass().isArray()) {
- return false;
- }
- Class<?> instanceComponentClass = instanceValue.getClass().getComponentType();
- Class<?> otherComponentClass = otherValue.getClass().getComponentType();
-
- if (!instanceComponentClass.isPrimitive()) {
- if (otherComponentClass.isPrimitive()) {
- return false;
- }
- if (!Arrays.deepEquals((Object[]) instanceValue, (Object[]) otherValue)) {
- return false;
- }
- }
- else { // instanceComponentClass is primative
- if (otherComponentClass != instanceComponentClass) {
- return false;
- }
-
- if (Boolean.TYPE == instanceComponentClass) {
- if(!Arrays.equals((boolean[]) instanceValue, (boolean[]) otherValue)) {
- return false;
- }
- }
- else if (Byte.TYPE == instanceComponentClass) {
- if (! Arrays.equals((byte[]) instanceValue, (byte[]) otherValue)) {
- return false;
- }
- }
- else if (Character.TYPE == instanceComponentClass) {
- if(!Arrays.equals((char[]) instanceValue, (char[]) otherValue)) {
- return false;
- }
- }
- else if (Short.TYPE == instanceComponentClass) {
- if(!Arrays.equals((short[]) instanceValue, (short[]) otherValue)) {
- return false;
- }
- }
- else if (Integer.TYPE == instanceComponentClass) {
- if(!Arrays.equals((int[]) instanceValue, (int[]) otherValue)) {
- return false;
- }
- }
- else if (Long.TYPE == instanceComponentClass) {
- if(!Arrays.equals((long[]) instanceValue, (long[]) otherValue)) {
- return false;
- }
- }
- else if (Float.TYPE == instanceComponentClass) {
- if(!Arrays.equals((float[]) instanceValue, (float[]) otherValue)) {
- return false;
- }
- }
- else if (Double.TYPE == instanceComponentClass) {
- if(!Arrays.equals((double[]) instanceValue, (double[]) otherValue)) {
- return false;
- }
- }
- else {
- // should NEVER happen
- throw new IllegalStateException(
- "unknown primative type " + instanceComponentClass.getName());
- }
- }
- }
- }
}
return true;
}
@@ -317,15 +240,128 @@
private PropertyElement propertyElement;
private PropertyFormatter propertyFormatter;
- public FormattablePropertyElement(PropertyElement propertyElement,
- PropertyFormatter propertyFormatter) {
+ public FormattablePropertyElement(
+ PropertyElement propertyElement, PropertyFormatter propertyFormatter) {
this.propertyElement = propertyElement;
this.propertyFormatter = propertyFormatter;
}
}
- public List<Difference> doDiff(T instance, T other) {
- // TODO Auto-generated method stub
- return null;
+ public Differences doDiff(T instance, T other) {
+ if (instance == null) {
+ throw new NullPointerException("instance is null");
+ }
+ if (other == null) {
+ return new DifferenceToNull(instance);
+ }
+ if (instance == other) {
+ return new PropertyDifferences(Collections.<Difference>emptyList());
+ }
+ if (!clazz.isInstance(other)) {
+ throw new ClassCastException(
+ "other has type " + other.getClass() + " which is not a subtype of " + clazz);
+ }
+ List<Difference> differences = new ArrayList<Difference>();
+ for (PropertyElement prop: classProperties.getEqualsProperties()) {
+ final Object instanceValue = prop.getValue(instance);
+ final Object otherValue = prop.getValue(other);
+ if (!areValuesEqual(instanceValue, otherValue)) {
+ differences.add(new Difference(prop.getName(), instanceValue, otherValue));
+ }
+ }
+ return new PropertyDifferences(differences);
}
+
+
+ /**
+ * @param instance
+ * @param other
+ * @return true if the values of properties referenced by {@code prop} in {@code instance} and
+ * {@code other} are equal to each other.
+ */
+ private static boolean areValuesEqual(Object instanceValue, Object otherValue) {
+ if (instanceValue == null) {
+ if (otherValue != null) {
+ return false;
+ }
+ }
+ else { // instanceValue is not null
+ if (otherValue == null) {
+ return false;
+ }
+ if (!instanceValue.getClass().isArray()) {
+ if (!instanceValue.equals(otherValue)) {
+ return false;
+ }
+ }
+ else {
+ if (!otherValue.getClass().isArray()) {
+ return false;
+ }
+ Class<?> instanceComponentClass = instanceValue.getClass().getComponentType();
+ Class<?> otherComponentClass = otherValue.getClass().getComponentType();
+
+ if (!instanceComponentClass.isPrimitive()) {
+ if (otherComponentClass.isPrimitive()) {
+ return false;
+ }
+ if (!Arrays.deepEquals((Object[]) instanceValue, (Object[]) otherValue)) {
+ return false;
+ }
+ }
+ else { // instanceComponentClass is primative
+ if (otherComponentClass != instanceComponentClass) {
+ return false;
+ }
+
+ if (Boolean.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((boolean[]) instanceValue, (boolean[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Byte.TYPE == instanceComponentClass) {
+ if (! Arrays.equals((byte[]) instanceValue, (byte[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Character.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((char[]) instanceValue, (char[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Short.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((short[]) instanceValue, (short[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Integer.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((int[]) instanceValue, (int[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Long.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((long[]) instanceValue, (long[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Float.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((float[]) instanceValue, (float[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Double.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((double[]) instanceValue, (double[]) otherValue)) {
+ return false;
+ }
+ }
+ else {
+ // should NEVER happen
+ throw new IllegalStateException(
+ "unknown primative type " + instanceComponentClass.getName());
+ }
+ }
+ }
+ }
+ return true;
+ }
}
Modified: trunk/Pojomatic/src/test/java/org/pojomatic/internal/PojomatorImplTest.java
===================================================================
--- trunk/Pojomatic/src/test/java/org/pojomatic/internal/PojomatorImplTest.java 2009-01-05 22:33:48 UTC (rev 87)
+++ trunk/Pojomatic/src/test/java/org/pojomatic/internal/PojomatorImplTest.java 2009-01-20 00:17:06 UTC (rev 88)
@@ -13,6 +13,10 @@
import org.pojomatic.annotations.PojoFormat;
import org.pojomatic.annotations.Property;
import org.pojomatic.annotations.PropertyFormat;
+import org.pojomatic.diff.Difference;
+import org.pojomatic.diff.DifferenceToNull;
+import org.pojomatic.diff.Differences;
+import org.pojomatic.diff.PropertyDifferences;
import org.pojomatic.formatter.DefaultPojoFormatter;
import org.pojomatic.formatter.DefaultPropertyFormatter;
@@ -203,6 +207,47 @@
makePojomatorImpl(FormattedObject.class).doToString(new FormattedObject("x")));
}
+ @Test(expected=NullPointerException.class) public void testDiffNullInstance() {
+ OBJECT_PAIR_PROPERTY_POJOMATOR.doDiff(null, new ObjectPairProperty("this", "that"));
+ }
+
+ @Test public void testDiffSameObject() {
+ ObjectPairProperty objectPairProperty = new ObjectPairProperty("this", "that");
+ assertTrue(
+ OBJECT_PAIR_PROPERTY_POJOMATOR.doDiff(objectPairProperty, objectPairProperty).areEqual());
+ }
+
+ @Test public void testDiffEqualObjects() {
+ assertTrue(
+ OBJECT_PAIR_PROPERTY_POJOMATOR.doDiff(
+ new ObjectPairProperty("this", "that"), new ObjectPairProperty("this", "that")).areEqual());
+ }
+
+ @Test public void testDiffDifferentObjectsWithSinglePropertyDifferent() {
+ final Differences diffs = OBJECT_PAIR_PROPERTY_POJOMATOR.doDiff(
+ new ObjectPairProperty("this", "that"), new ObjectPairProperty("THIS", "that"));
+ assertTrue(diffs instanceof PropertyDifferences);
+ assertEquals(
+ Arrays.asList(new Difference("s", "this", "THIS")),
+ ((PropertyDifferences) diffs).getDifferences());
+ }
+
+ @Test public void testDiffDifferentObjectsWithMultiplePropertiesDifferent() {
+ final Differences diffs = OBJECT_PAIR_PROPERTY_POJOMATOR.doDiff(
+ new ObjectPairProperty("this", "that"), new ObjectPairProperty("THIS", "THAT"));
+ assertEquals(PropertyDifferences.class, diffs.getClass());
+ assertEquals(
+ Arrays.asList(new Difference("s", "this", "THIS"), new Difference("t", "that", "THAT")),
+ ((PropertyDifferences) diffs).getDifferences());
+ }
+
+ @Test public void testDiffAgainstNull() {
+ ObjectPairProperty instance = new ObjectPairProperty("this", "that");
+ Differences differences = OBJECT_PAIR_PROPERTY_POJOMATOR.doDiff(instance, null);
+ assertFalse(differences.areEqual());
+ assertEquals(DifferenceToNull.class, differences.getClass());
+ }
+
@PojoFormat(SimplePojoFormatter.class)
private static class FormattedObject {
public FormattedObject(Object s) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2009-01-05 22:33:51
|
Revision: 87
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=87&view=rev
Author: chriswhansen
Date: 2009-01-05 22:33:48 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Added initial API for Pojomatic.diff() for later implementation and documentation
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java
trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java
trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
Added Paths:
-----------
trunk/Pojomatic/src/main/java/org/pojomatic/diff/
trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2008-12-31 23:24:43 UTC (rev 86)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2009-01-05 22:33:48 UTC (rev 87)
@@ -1,5 +1,8 @@
package org.pojomatic;
+import java.util.List;
+
+import org.pojomatic.diff.Difference;
import org.pojomatic.internal.PojomatorImpl;
import org.pojomatic.internal.SelfPopulatingMap;
@@ -116,4 +119,8 @@
private static <T> Class<T> getClass(T pojo) {
return (Class<T>) pojo.getClass();
}
+
+ public static <T, S extends T> List<Difference> diff(T lhs, S rhs) {
+ return null; //TODO
+ }
}
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java 2008-12-31 23:24:43 UTC (rev 86)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/Pojomator.java 2009-01-05 22:33:48 UTC (rev 87)
@@ -1,5 +1,9 @@
package org.pojomatic;
+import java.util.List;
+
+import org.pojomatic.diff.Difference;
+
/**
* An automatically generated provider of the three standard {@code Object} methods,
* {@link Object#equals(Object)}, {@link Object#hashCode()} and {@link Object#toString()}.
@@ -37,4 +41,15 @@
* @see Object#equals(Object)
*/
boolean doEquals(T instance, Object other);
+
+ /**
+ * Compute the differences between {@code instance} and {@code other} among the properties
+ * examined by {@link #doEquals(Object, Object)}.
+ *
+ * @param instance the instance to diff against - must not be {@code null}
+ * @param other the instance to diff
+ * @return the list of differences (possibly empty) between {@code instance} and {@code other}
+ * among the properties examined by {@link #doEquals(Object, Object)}.
+ */
+ List<Difference> doDiff(T instance, T other);
}
Added: trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java (rev 0)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/diff/Difference.java 2009-01-05 22:33:48 UTC (rev 87)
@@ -0,0 +1,46 @@
+package org.pojomatic.diff;
+
+import org.pojomatic.Pojomatic;
+import org.pojomatic.annotations.AutoProperty;
+
+@AutoProperty
+public class Difference {
+ private final String propertyName;
+ private final Object lhs;
+ private final Object rhs;
+
+ public Difference(String propertyName, Object lhs, Object rhs) {
+ this.propertyName = propertyName;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public Object getLhs() {
+ return lhs;
+ }
+
+ public Object getRhs() {
+ return rhs;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return Pojomatic.equals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return Pojomatic.hashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ // TODO implement a sensible String representation
+ return super.toString();
+ }
+
+}
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-31 23:24:43 UTC (rev 86)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2009-01-05 22:33:48 UTC (rev 87)
@@ -10,6 +10,7 @@
import org.pojomatic.annotations.PojoFormat;
import org.pojomatic.annotations.PojomaticPolicy;
import org.pojomatic.annotations.PropertyFormat;
+import org.pojomatic.diff.Difference;
import org.pojomatic.formatter.DefaultPojoFormatter;
import org.pojomatic.formatter.DefaultPropertyFormatter;
import org.pojomatic.formatter.PojoFormatter;
@@ -322,4 +323,9 @@
this.propertyFormatter = propertyFormatter;
}
}
+
+ public List<Difference> doDiff(T instance, T other) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-31 23:24:53
|
Revision: 86
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=86&view=rev
Author: iroberts
Date: 2008-12-31 23:24:43 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
[maven-release-plugin] prepare for next development iteration
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-12-31 23:24:39 UTC (rev 85)
+++ trunk/Pojomatic/pom.xml 2008-12-31 23:24:43 UTC (rev 86)
@@ -3,7 +3,7 @@
<groupId>org.pojomatic</groupId>
<artifactId>pojomatic</artifactId>
<packaging>jar</packaging>
- <version>1.0-RC1</version>
+ <version>SNAPSHOT</version>
<name>Pojomatic</name>
<description>
Automatically provides configurable implementations of the
@@ -12,9 +12,9 @@
<url>http://www.pojomatic.org</url>
<inceptionYear>2008</inceptionYear>
<scm>
- <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</connection>
- <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</developerConnection>
- <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</url>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</url>
</scm>
<developers>
<developer>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-31 23:24:43
|
Revision: 85
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=85&view=rev
Author: iroberts
Date: 2008-12-31 23:24:39 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
[maven-release-plugin] copy for tag pojomatic-1.0-RC1
Added Paths:
-----------
tags/pojomatic-1.0-RC1/
tags/pojomatic-1.0-RC1/pom.xml
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java
tags/pojomatic-1.0-RC1/src/main/javadoc/overview.html
tags/pojomatic-1.0-RC1/src/site/apt/index.apt
tags/pojomatic-1.0-RC1/src/site/resources/
tags/pojomatic-1.0-RC1/src/site/site.xml
tags/pojomatic-1.0-RC1/src/test/java/examples/Auto.java
tags/pojomatic-1.0-RC1/src/test/java/examples/Customer.java
Removed Paths:
-------------
tags/pojomatic-1.0-RC1/pom.xml
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java
tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java
tags/pojomatic-1.0-RC1/src/main/javadoc/overview.html
tags/pojomatic-1.0-RC1/src/site/apt/index.apt
tags/pojomatic-1.0-RC1/src/test/java/examples/Auto.java
Deleted: tags/pojomatic-1.0-RC1/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-12-02 18:09:19 UTC (rev 74)
+++ tags/pojomatic-1.0-RC1/pom.xml 2008-12-31 23:24:39 UTC (rev 85)
@@ -1,157 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.pojomatic</groupId>
- <artifactId>pojomatic</artifactId>
- <packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
- <name>Pojomatic</name>
- <description>
- Automatically provides configurable implementations of the
- equals(Object), toString() and hashCode() methods inherited from java.lang.Object
- </description>
- <url>http://www.pojomatic.org</url>
- <inceptionYear>2008</inceptionYear>
- <scm>
- <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</connection>
- <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</developerConnection>
- <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</url>
- </scm>
- <developers>
- <developer>
- <name>Ian Robertson</name>
- <roles>
- <role>Lead Developer</role>
- </roles>
- <email>ian...@gm...</email>
- <id>ian.b.robertson</id>
- <organization>Overstock.com</organization>
- <organizationUrl>http://www.overstock.com</organizationUrl>
- <url>http://www.artima.com/weblogs/index.jsp?blogger=ianr</url>
- </developer>
- <developer>
- <name>Chris Hansen</name>
- <roles>
- <role>Lead Developer</role>
- </roles>
- <email>han...@gm...</email>
- <id>hansen.chris.w</id>
- <organization>Overstock.com</organization>
- <organizationUrl>http://www.overstock.com</organizationUrl>
- <url>http://polyglot-window.blogspot.com/</url>
- </developer>
- </developers>
- <licenses>
- <license>
- <name>Apache License 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <issueManagement>
- <system>Sourceforge</system>
- <url>https://sourceforge.net/tracker/?func=browse&group_id=239113</url>
- </issueManagement>
- <distributionManagement>
- <repository>
- <id>pojomatic-releases</id>
- <name>Pojomatic Release Repository</name>
- <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/releases</url>
- </repository>
- <snapshotRepository>
- <id>pojomatic-snapshots</id>
- <name>Pojomatic snapshot Repository</name>
- <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/snapshots</url>
- </snapshotRepository>
- <site>
- <id>pojomatic-site</id>
- <name>Pojomatic</name>
- <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/htdocs/site</url>
- </site>
- </distributionManagement>
- <mailingLists>
- <mailingList>
- <archive>http://sourceforge.net/mailarchive/forum.php?forum_name=pojomatic-users</archive>
- <name>pojomatic-users</name>
- <post>poj...@li...</post>
- <subscribe>http://lists.sourceforge.net/mailman/listinfo/pojomatic-users</subscribe>
- <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/pojomatic-users</unsubscribe>
- </mailingList>
- </mailingLists>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
- <configuration>
- <excludes>
- <exclude>**/TestUtils.java</exclude>
- <exclude>examples/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.4</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-5</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>1.1.1</version>
- <configuration>
- <excludeFilterFile>${basedir}/FindBugsFilter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.4.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- <rulesets>
- <ruleset>${project.basedir}/src/pmd.xml</ruleset>
- </rulesets>
- <includeTests>true</includeTests>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- </plugins>
- </reporting>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: tags/pojomatic-1.0-RC1/pom.xml (from rev 84, trunk/Pojomatic/pom.xml)
===================================================================
--- tags/pojomatic-1.0-RC1/pom.xml (rev 0)
+++ tags/pojomatic-1.0-RC1/pom.xml 2008-12-31 23:24:39 UTC (rev 85)
@@ -0,0 +1,158 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.pojomatic</groupId>
+ <artifactId>pojomatic</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-RC1</version>
+ <name>Pojomatic</name>
+ <description>
+ Automatically provides configurable implementations of the
+ equals(Object), toString() and hashCode() methods inherited from java.lang.Object
+ </description>
+ <url>http://www.pojomatic.org</url>
+ <inceptionYear>2008</inceptionYear>
+ <scm>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</url>
+ </scm>
+ <developers>
+ <developer>
+ <name>Ian Robertson</name>
+ <roles>
+ <role>Lead Developer</role>
+ </roles>
+ <email>ian...@gm...</email>
+ <id>ian.b.robertson</id>
+ <organization>Overstock.com</organization>
+ <organizationUrl>http://www.overstock.com</organizationUrl>
+ <url>http://www.artima.com/weblogs/index.jsp?blogger=ianr</url>
+ </developer>
+ <developer>
+ <name>Chris Hansen</name>
+ <roles>
+ <role>Lead Developer</role>
+ </roles>
+ <email>han...@gm...</email>
+ <id>hansen.chris.w</id>
+ <organization>Overstock.com</organization>
+ <organizationUrl>http://www.overstock.com</organizationUrl>
+ <url>http://polyglot-window.blogspot.com/</url>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>Apache License 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <issueManagement>
+ <system>Sourceforge</system>
+ <url>https://sourceforge.net/tracker/?func=browse&group_id=239113</url>
+ </issueManagement>
+ <distributionManagement>
+ <repository>
+ <id>pojomatic-releases</id>
+ <name>Pojomatic Release Repository</name>
+ <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/releases</url>
+ </repository>
+ <snapshotRepository>
+ <id>pojomatic-snapshots</id>
+ <name>Pojomatic snapshot Repository</name>
+ <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/snapshots</url>
+ </snapshotRepository>
+ <site>
+ <id>pojomatic-site</id>
+ <name>Pojomatic</name>
+ <!-- before deploying, you'll need to run ssh <username>,poj...@sh... create -->
+ <url>scp://shell.sourceforge.net/home/groups/p/po/pojomatic/htdocs</url>
+ </site>
+ </distributionManagement>
+ <mailingLists>
+ <mailingList>
+ <archive>http://sourceforge.net/mailarchive/forum.php?forum_name=pojomatic-users</archive>
+ <name>pojomatic-users</name>
+ <post>poj...@li...</post>
+ <subscribe>http://lists.sourceforge.net/mailman/listinfo/pojomatic-users</subscribe>
+ <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/pojomatic-users</unsubscribe>
+ </mailingList>
+ </mailingLists>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
+ <configuration>
+ <excludes>
+ <exclude>**/TestUtils.java</exclude>
+ <exclude>examples/*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.0-beta-5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <configuration>
+ <excludeFilterFile>${basedir}/FindBugsFilter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.4.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <targetJdk>1.5</targetJdk>
+ <rulesets>
+ <ruleset>${project.basedir}/src/pmd.xml</ruleset>
+ </rulesets>
+ <includeTests>true</includeTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2008-12-02 18:09:19 UTC (rev 74)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -1,96 +0,0 @@
-package org.pojomatic;
-
-import org.pojomatic.internal.PojomatorImpl;
-import org.pojomatic.internal.SelfPopulatingMap;
-
-/**
- * Static convenience methods for working with {@code Pojomator}s. This class is carefull to create
- * only a single {@code Pojomator} per pojo class. The overhead for looking up the {@code Pojomator}
- * by pojo class is light, so a a typical use in a pojo class would be
- * <p>
- * <code>
- * <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode() {</font><br>
- * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomator.hashCode(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
- * <font color="#000000">}</font><br>
- * <br/>
- * <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals(Object other) {</font><br>
- * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomator.equals(</font><font color="#7f0055"><b>this</b></font><font color="#000000">, other);</font><br />
- * <font color="#000000">}</font><br>
- * <br/>
- * <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#000000">String toString() {</font><br>
- * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomator.toString(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
- * <font color="#000000">}</font><br>
- * <br/>
- * </code>
- * </p>
- *
- * @see Pojomator
- */
-public class Pojomatic {
-
- private static SelfPopulatingMap<Class<?>, Pojomator<?>> POJOMATORS =
- new SelfPopulatingMap<Class<?>, Pojomator<?>>() {
- @Override
- @SuppressWarnings("unchecked")
- // compiler does not know that the type parameter to Pojomator is the same as the type
- // parameter to Class
- protected Pojomator<?> create(Class<?> key) {
- return new PojomatorImpl(key);
- }
- };
-
- private Pojomatic() {}
-
- /**
- * Compute the {@code toString} representation for a pojo.
- * @param <T> the type of the pojo
- * @param pojo the pojo - must not be null
- * @return the {@code toString} representation of {@code pojo}.
- * @see Pojomator#doToString(Object)
- */
- public static <T> String toString(T pojo) {
- return pojomator(getClass(pojo)).doToString(pojo);
- }
-
- /**
- * Compute the {@code hashCode} for a pojo.
- * @param <T> the type of the pojo
- * @param pojo the pojo - must not be null
- * @return the {@code hashCode} for {@code pojo}.
- * @see Pojomator#doHashCode(Object)
- */
- public static <T> int hashCode(T pojo) {
- return pojomator(getClass(pojo)).doHashCode(pojo);
- }
-
- /**
- * Compute whether {@code pojo} and {@code other} are equal to each other in the sense of
- * {@code Object}'s {@code equals} method.
- * @param <T> the type of the pojo
- * @param pojo the pojo - must not be null
- * @param other the object to compare to for equality
- * @return whether {@code pojo} and {@code other} are equal to each other in the sense of
- * {@code Object}'s {@code equals} method.
- * @see Pojomator#doEquals(Object, Object)
- */
- public static <T> boolean equals(T pojo, Object other) {
- return pojomator(getClass(pojo)).doEquals(pojo, other);
- }
-
- /**
- * Get the {@code Pojomator} for {@code pojoClass}. The same instance will be returned every time
- * for a given value of {@code pojoClass}.
- * @param <T> the type represented by {@code pojoClass}
- * @param pojoClass the class to create a {@code Pojomator} for.
- * @return a {@code Pojomator<T>}
- */
- @SuppressWarnings("unchecked") // compiler does not know that the type parameter to Pojomator is T
- public static <T> Pojomator<T> pojomator(Class<T> pojoClass) {
- return (Pojomator<T>) POJOMATORS.get(pojoClass);
- }
-
- @SuppressWarnings("unchecked") // Since Object.getClass returns Class<?>
- private static <T> Class<T> getClass(T pojo) {
- return (Class<T>) pojo.getClass();
- }
-}
Copied: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java (from rev 76, trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java)
===================================================================
--- tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java (rev 0)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/Pojomatic.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -0,0 +1,119 @@
+package org.pojomatic;
+
+import org.pojomatic.internal.PojomatorImpl;
+import org.pojomatic.internal.SelfPopulatingMap;
+
+/**
+ * Static methods for implementing the {@link java.lang.Object#equals(Object)},
+ * {@link java.lang.Object#hashCode()} and {@link java.lang.Object#toString()} methods on a
+ * annotated POJO. The actual work for a given class is done by a {@link Pojomator} created for
+ * that class. This class is careful to create only a single {@code Pojomator} per POJO class.
+ * The overhead for looking up the {@code Pojomator} by POJO class is light, so a typical use in a
+ * POJO class would be
+ * <p style="background-color:#EEEEFF; margin: 1em">
+ * <code>
+ * <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode() {</font><br>
+ * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.hashCode(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
+ * <font color="#000000">}</font><br>
+ * <br/>
+ * <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals(Object other) {</font><br>
+ * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.equals(</font><font color="#7f0055"><b>this</b></font><font color="#000000">, other);</font><br />
+ * <font color="#000000">}</font><br>
+ * <br/>
+ * <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#000000">String toString() {</font><br>
+ * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.toString(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
+ * <font color="#000000">}</font><br>
+ * <br/>
+ * </code>
+ * </p>
+ * Under the covers, these methods are referencing a {@link org.pojomatic.Pojomator Pojomator} instance
+ * which is created lazily and cached on a per-class basis. The performance penalty for this is
+ * negligible, but if profiling suggests that it is a bottleneck, one can do this by hand:
+ * <p style="background-color:#EEEEFF; margin: 1em">
+ * <code>
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>private final static </b></font><font color="#000000">Pojomator<Manual> POJOMATOR = Pojomatic.pojomator</font><font color="#000000">(</font><font color="#000000">Manual.</font><font color="#7f0055"><b>class</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"></font><br />
+ * <font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object other</font><font color="#000000">) {</font><br />
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doEquals</font><font color="#000000">(</font><font color="#000000">this, other</font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"> </font><font color="#000000">}</font><br />
+ * <font color="#ffffff"></font><br />
+ * <font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doHashCode</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"> </font><font color="#000000">}</font><br />
+ * <font color="#ffffff"></font><br />
+ * <font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#000000">String toString</font><font color="#000000">() {</font><br />
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doToString</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"> </font><font color="#000000">}</font>
+ * </code>
+ * </p>
+ *
+ * @see Pojomator
+ */
+public class Pojomatic {
+
+ private static SelfPopulatingMap<Class<?>, Pojomator<?>> POJOMATORS =
+ new SelfPopulatingMap<Class<?>, Pojomator<?>>() {
+ @Override
+ @SuppressWarnings("unchecked")
+ // compiler does not know that the type parameter to Pojomator is the same as the type
+ // parameter to Class
+ protected Pojomator<?> create(Class<?> key) {
+ return new PojomatorImpl(key);
+ }
+ };
+
+ private Pojomatic() {}
+
+ /**
+ * Compute the {@code toString} representation for a POJO.
+ * @param <T> the type of the POJO
+ * @param pojo the POJO - must not be null
+ * @return the {@code toString} representation of {@code pojo}.
+ * @see Pojomator#doToString(Object)
+ */
+ public static <T> String toString(T pojo) {
+ return pojomator(getClass(pojo)).doToString(pojo);
+ }
+
+ /**
+ * Compute the {@code hashCode} for a POJO.
+ * @param <T> the type of the POJO
+ * @param pojo the POJO - must not be null
+ * @return the {@code hashCode} for {@code pojo}.
+ * @see Pojomator#doHashCode(Object)
+ */
+ public static <T> int hashCode(T pojo) {
+ return pojomator(getClass(pojo)).doHashCode(pojo);
+ }
+
+ /**
+ * Compute whether {@code pojo} and {@code other} are equal to each other in the sense of
+ * {@code Object}'s {@code equals} method.
+ * @param <T> the type of the POJO
+ * @param pojo the POJO - must not be null
+ * @param other the object to compare to for equality
+ * @return whether {@code pojo} and {@code other} are equal to each other in the sense of
+ * {@code Object}'s {@code equals} method.
+ * @see Pojomator#doEquals(Object, Object)
+ */
+ public static <T> boolean equals(T pojo, Object other) {
+ return pojomator(getClass(pojo)).doEquals(pojo, other);
+ }
+
+ /**
+ * Get the {@code Pojomator} for {@code pojoClass}. The same instance will be returned every time
+ * for a given value of {@code pojoClass}.
+ * @param <T> the type represented by {@code pojoClass}
+ * @param pojoClass the class to create a {@code Pojomator} for.
+ * @return a {@code Pojomator<T>}
+ */
+ @SuppressWarnings("unchecked") // compiler does not know that the type parameter to Pojomator is T
+ public static <T> Pojomator<T> pojomator(Class<T> pojoClass) {
+ return (Pojomator<T>) POJOMATORS.get(pojoClass);
+ }
+
+ @SuppressWarnings("unchecked") // Since Object.getClass returns Class<?>
+ private static <T> Class<T> getClass(T pojo) {
+ return (Class<T>) pojo.getClass();
+ }
+}
Deleted: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PropertyFormat.java 2008-12-02 18:09:19 UTC (rev 74)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -1,26 +0,0 @@
-package org.pojomatic.annotations;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import org.pojomatic.formatter.PropertyFormatter;
-
-/**
- * Specifies formatting information to be used for creating {@code String} representations of properties.
- * @see PropertyFormatter
- */
-@Target({FIELD, METHOD})
-@Retention(RUNTIME)
-@Documented
-public @interface PropertyFormat {
-
- /**
- * The formatter to use for creating a {@code String} representation.
- */
- public Class<? extends PropertyFormatter> value();
-}
Copied: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java (from rev 75, trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PropertyFormat.java)
===================================================================
--- tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java (rev 0)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/annotations/PropertyFormat.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -0,0 +1,29 @@
+package org.pojomatic.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.pojomatic.formatter.PropertyFormatter;
+
+/**
+ * Specifies formatting information to be used for creating {@code String} representations of
+ * properties. Note that using a {@code PropertyFormat} annotation on a property does not influence
+ * whether that property will be included in the {@code toString} implementation. That is
+ * determined solely by any {@link Property} and {@link AutoProperty} annotations on the POJO.
+ * @see PropertyFormatter
+ */
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface PropertyFormat {
+
+ /**
+ * The formatter to use for creating a {@code String} representation.
+ */
+ public Class<? extends PropertyFormatter> value();
+}
Deleted: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java 2008-12-02 18:09:19 UTC (rev 74)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -1,36 +0,0 @@
-package org.pojomatic.formatter;
-
-import org.pojomatic.Pojomatic;
-import org.pojomatic.PropertyElement;
-
-/**
- * Default formatter for classes that use {@link Pojomatic}.
- * For example,
- * TODO provide an example
- */
-public class DefaultPojoFormatter implements PojoFormatter {
- private boolean firstPropertyPrinted = false;
-
- public String getPropertyPrefix(PropertyElement property) {
- StringBuilder result = new StringBuilder();
- if (firstPropertyPrinted) {
- result.append(", ");
- }
- else {
- firstPropertyPrinted = true;
- }
- return result.append(property.getName()).append(": {").toString();
- }
-
- public String getPropertySuffix(PropertyElement property) {
- return "}";
- }
-
- public String getToStringPrefix(Class<?> pojoClass) {
- return pojoClass.getSimpleName() + "{";
- }
-
- public String getToStringSuffix(Class<?> pojoClass) {
- return "}";
- }
-}
Copied: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java (from rev 81, trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java)
===================================================================
--- tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java (rev 0)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -0,0 +1,41 @@
+package org.pojomatic.formatter;
+
+import org.pojomatic.Pojomatic;
+import org.pojomatic.PropertyElement;
+
+/**
+ * Default formatter for classes that use {@link Pojomatic}. This implementation first presents
+ * the class name, and then each property in turn, separated by commas, using braces to indicate
+ * nesting.
+ * <p>
+ * For example, if a class Person has two properties, firstName and LastName, and these properties
+ * are using {@link DefaultPropertyFormatter}, then the Person
+ * instance representing Joe Blow would be represented as
+ * <code>"Person{firstName: {Joe}, lastName: {Blow}}"</code>
+ */
+public class DefaultPojoFormatter implements PojoFormatter {
+ private boolean firstPropertyPrinted = false;
+
+ public String getPropertyPrefix(PropertyElement property) {
+ StringBuilder result = new StringBuilder();
+ if (firstPropertyPrinted) {
+ result.append(", ");
+ }
+ else {
+ firstPropertyPrinted = true;
+ }
+ return result.append(property.getName()).append(": {").toString();
+ }
+
+ public String getPropertySuffix(PropertyElement property) {
+ return "}";
+ }
+
+ public String getToStringPrefix(Class<?> pojoClass) {
+ return pojoClass.getSimpleName() + "{";
+ }
+
+ public String getToStringSuffix(Class<?> pojoClass) {
+ return "}";
+ }
+}
Deleted: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/formatter/PojoFormatter.java 2008-12-02 18:09:19 UTC (rev 74)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -1,50 +0,0 @@
-package org.pojomatic.formatter;
-
-import org.pojomatic.PropertyElement;
-import org.pojomatic.internal.PojomatorImpl;
-
-/**
- * A formatter to aid in creating a {@code String} representation of a Pojo. A new instance will be
- * created for each time that {@link PojomatorImpl#doToString(Object)} is called.
- *
- * @see PojomatorImpl#doToString(Object)
- */
-public interface PojoFormatter {
-
- /**
- * Get the {@code String} which should appear at the beginning of the result of
- * {@code toString()}.
- *
- * @param pojoClass the class for which {@code toString()} is being called
- * @return the prefix to appear at the beginning of the result of {@code toString()}
- * @see Object#toString()
- */
- String getToStringPrefix(Class<?> pojoClass);
-
- /**
- * Get the {@code String} which should appear at the end of the result of
- * {@code toString()}.
- * @param pojoClass the class for which {@code toString()} is being called
- * @return the suffix to appear at the end of the result of {@code toString()}
- * @see Object#toString()
- */
- String getToStringSuffix(Class<?> pojoClass);
-
- /**
- * Get the {@code String} prefix for a given {@code PropertyElement}. This method will be called
- * once for each property used in the result of {@code toString()}, in the order in which
- * those properties will appear in that result, and before the call to
- * {@link PropertyFormatter#format(Object)} for the property's value.
- * @param property the property for which to generate a prefix
- * @return the prefix for the given property
- */
- String getPropertyPrefix(PropertyElement property);
-
- /**
- * Get the {@code String} suffix for a given {@code PropertyElement}. This method will be called
- * once after each call to {@link PropertyFormatter#format(Object)} for the property's value.
- * @param property the property for which to generate a suffix
- * @return the suffix for the given property
- */
- String getPropertySuffix(PropertyElement property);
-}
Copied: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java (from rev 76, trunk/Pojomatic/src/main/java/org/pojomatic/formatter/PojoFormatter.java)
===================================================================
--- tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java (rev 0)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/formatter/PojoFormatter.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -0,0 +1,50 @@
+package org.pojomatic.formatter;
+
+import org.pojomatic.PropertyElement;
+import org.pojomatic.internal.PojomatorImpl;
+
+/**
+ * A formatter to aid in creating a {@code String} representation of a POJO. A new instance will be
+ * created for each time that {@link PojomatorImpl#doToString(Object)} is called.
+ *
+ * @see PojomatorImpl#doToString(Object)
+ */
+public interface PojoFormatter {
+
+ /**
+ * Get the {@code String} which should appear at the beginning of the result of
+ * {@code toString()}.
+ *
+ * @param pojoClass the class for which {@code toString()} is being called
+ * @return the prefix to appear at the beginning of the result of {@code toString()}
+ * @see Object#toString()
+ */
+ String getToStringPrefix(Class<?> pojoClass);
+
+ /**
+ * Get the {@code String} which should appear at the end of the result of
+ * {@code toString()}.
+ * @param pojoClass the class for which {@code toString()} is being called
+ * @return the suffix to appear at the end of the result of {@code toString()}
+ * @see Object#toString()
+ */
+ String getToStringSuffix(Class<?> pojoClass);
+
+ /**
+ * Get the {@code String} prefix for a given {@code PropertyElement}. This method will be called
+ * once for each property used in the result of {@code toString()}, in the order in which
+ * those properties will appear in that result, and before the call to
+ * {@link PropertyFormatter#format(Object)} for the property's value.
+ * @param property the property for which to generate a prefix
+ * @return the prefix for the given property
+ */
+ String getPropertyPrefix(PropertyElement property);
+
+ /**
+ * Get the {@code String} suffix for a given {@code PropertyElement}. This method will be called
+ * once after each call to {@link PropertyFormatter#format(Object)} for the property's value.
+ * @param property the property for which to generate a suffix
+ * @return the suffix for the given property
+ */
+ String getPropertySuffix(PropertyElement property);
+}
Deleted: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-02 18:09:19 UTC (rev 74)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -1,292 +0,0 @@
-package org.pojomatic.internal;
-
-import java.lang.reflect.AnnotatedElement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.pojomatic.Pojomator;
-import org.pojomatic.PropertyElement;
-import org.pojomatic.annotations.PojoFormat;
-import org.pojomatic.annotations.PropertyFormat;
-import org.pojomatic.formatter.DefaultPojoFormatter;
-import org.pojomatic.formatter.DefaultPropertyFormatter;
-import org.pojomatic.formatter.PojoFormatter;
-import org.pojomatic.formatter.PropertyFormatter;
-
-public class PojomatorImpl<T> implements Pojomator<T>{
- final static int HASH_CODE_SEED = 1;
- final static int HASH_CODE_MULTIPLIER = 31;
-
-
- public PojomatorImpl(Class<T> clazz) {
- this.clazz = clazz;
- classProperties = new ClassProperties(clazz);
- pojoFormatterClass = findPojoFormatterClass(clazz);
- for (PropertyElement prop: classProperties.getToStringProperties()) {
- PropertyFormatter propertyFormatter = findPropertyFormatter(prop.getElement());
- propertyFormatter.initialize(prop.getElement());
- formattablePropertyElements.add(new FormattablePropertyElement(prop, propertyFormatter));
- }
- }
-
- private static PropertyFormatter findPropertyFormatter(AnnotatedElement element) {
- PropertyFormat format = element.getAnnotation(PropertyFormat.class);
- try {
- return (format == null ? DefaultPropertyFormatter.class : format.value()).newInstance();
- }
- catch (InstantiationException e) {
- //TODO log this?
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e) {
- //TODO log this?
- throw new RuntimeException(e);
- }
- }
-
- private static Class<? extends PojoFormatter> findPojoFormatterClass(Class<?> clazz) {
- PojoFormat format = clazz.getAnnotation(PojoFormat.class);
- return format == null ? DefaultPojoFormatter.class : format.value();
- }
-
- public boolean doEquals(T instance, Object other) {
- if (instance == null) {
- throw new NullPointerException("instance must not be null");
- }
- if (instance == other) {
- return true;
- }
- if (! clazz.isInstance(other)) {
- return false;
- }
-
- for (PropertyElement prop: classProperties.getEqualsProperties()) {
- Object instanceValue = prop.getValue(instance);
- Object otherValue = prop.getValue(other);
- if (instanceValue == null) {
- if (otherValue != null) {
- return false;
- }
- }
- else { // instanceValue is not null
- if (otherValue == null) {
- return false;
- }
- if (!instanceValue.getClass().isArray()) {
- if (!instanceValue.equals(otherValue)) {
- return false;
- }
- }
- else {
- if (!otherValue.getClass().isArray()) {
- return false;
- }
- //TODO - decide if we should choose to enter this branch based off of the property's
- // declared or runtime type. Either way, document the choice. For now, runtime.
- Class<?> instanceComponentClass = instanceValue.getClass().getComponentType();
- Class<?> otherComponentClass = otherValue.getClass().getComponentType();
-
- if (!instanceComponentClass.isPrimitive()) {
- if (otherComponentClass.isPrimitive()) {
- return false;
- }
- if (!Arrays.deepEquals((Object[]) instanceValue, (Object[]) otherValue)) {
- return false;
- }
- }
- else { // instanceComponentClass is primative
- if (otherComponentClass != instanceComponentClass) {
- return false;
- }
-
- if (Boolean.TYPE == instanceComponentClass) {
- if(!Arrays.equals((boolean[]) instanceValue, (boolean[]) otherValue)) {
- return false;
- }
- }
- else if (Byte.TYPE == instanceComponentClass) {
- if (! Arrays.equals((byte[]) instanceValue, (byte[]) otherValue)) {
- return false;
- }
- }
- else if (Character.TYPE == instanceComponentClass) {
- if(!Arrays.equals((char[]) instanceValue, (char[]) otherValue)) {
- return false;
- }
- }
- else if (Short.TYPE == instanceComponentClass) {
- if(!Arrays.equals((short[]) instanceValue, (short[]) otherValue)) {
- return false;
- }
- }
- else if (Integer.TYPE == instanceComponentClass) {
- if(!Arrays.equals((int[]) instanceValue, (int[]) otherValue)) {
- return false;
- }
- }
- else if (Long.TYPE == instanceComponentClass) {
- if(!Arrays.equals((long[]) instanceValue, (long[]) otherValue)) {
- return false;
- }
- }
- else if (Float.TYPE == instanceComponentClass) {
- if(!Arrays.equals((float[]) instanceValue, (float[]) otherValue)) {
- return false;
- }
- }
- else if (Double.TYPE == instanceComponentClass) {
- if(!Arrays.equals((double[]) instanceValue, (double[]) otherValue)) {
- return false;
- }
- }
- else {
- // should NEVER happen
- throw new IllegalStateException(
- "unknown primative type " + instanceComponentClass.getName());
- }
- }
- }
- }
- }
- return true;
- }
-
- public int doHashCode(T instance) {
- int hashCode = HASH_CODE_SEED;
- if (instance == null) {
- throw new NullPointerException("instance must not be null");
- }
- for (PropertyElement prop: classProperties.getHashCodeProperties()) {
- Object value = prop.getValue(instance);
- hashCode = HASH_CODE_MULTIPLIER * hashCode + (hashCodeOfValue(value));
- }
- return hashCode;
- }
-
- private int hashCodeOfValue(Object value) {
- if (value == null) {
- return 0;
- }
- else {
- if (value.getClass().isArray()) {
- Class<?> instanceComponentClass = value.getClass().getComponentType();
- if (! instanceComponentClass.isPrimitive()) {
- return Arrays.hashCode((Object[]) value);
- }
- else {
- if (Boolean.TYPE == instanceComponentClass) {
- return Arrays.hashCode((boolean[]) value);
- }
- else if (Byte.TYPE == instanceComponentClass) {
- return Arrays.hashCode((byte[]) value);
- }
- else if (Character.TYPE == instanceComponentClass) {
- return Arrays.hashCode((char[]) value);
- }
- else if (Short.TYPE == instanceComponentClass) {
- return Arrays.hashCode((short[]) value);
- }
- else if (Integer.TYPE == instanceComponentClass) {
- return Arrays.hashCode((int[]) value);
- }
- else if (Long.TYPE == instanceComponentClass) {
- return Arrays.hashCode((long[]) value);
- }
- else if (Float.TYPE == instanceComponentClass) {
- return Arrays.hashCode((float[]) value);
- }
- else if (Double.TYPE == instanceComponentClass) {
- return Arrays.hashCode((double[]) value);
- }
- else {
- // should NEVER happen
- throw new IllegalStateException(
- "unknown primative type " + instanceComponentClass.getName());
- }
- }
- }
- else {
- return value.hashCode();
- }
- }
- }
-
- /**
- * Creates the {@code String} representation of the given instance. The format used depends on the
- * {@link PojoFormatter} used for the pojo, and the {@link PropertyFormatter} of each property.
- * <p>
- * For example, suppose a class {@code Person} has properties {@code firstName} and
- * {@code lastName} which are included in its {@code String} representation.
- * No {@code PojoFormatter} or {@code PropertyFormatter} are specified, so the defaults are used.
- * In particular, instances of {@code DefaultPropertyFormatter} will be created for
- * {@code firstName} and {@code lastName} (referred to here as {@code firstNameFormatter} and
- * {@code lastNameFormatter}, respectively). Let {@code firstNameProperty} and
- * {@code lastNameProperty} refer to the instances of {@link PropertyElement} referring to the
- * properties {@code firstName} and {@code lastName} respectively.
- * </p>
- * <p>
- * For a non-null {@code Person} instance, the {@code String} representation will be created by
- * creating an instance of {@code DefaultPojoFormatter} for the {@code Person} class (referred to
- * here as {@code personFormatter}), and then concatenating the results of following:
- * <ol>
- * <li>{@link DefaultPojoFormatter#getToStringPrefix(Class) personFormatter.getToStringPrefix(Person.class)}</li>
- * <li>{@link DefaultPojoFormatter#getPropertyPrefix(PropertyElement) personFormatter.getPropertyPrefix(firstNameProperty)}</li>
- * <li>{@link DefaultPropertyFormatter#format(Object) firstNameFormatter.format(firstName)}</li>
- * <li>{@link DefaultPojoFormatter#getPropertySuffix(PropertyElement) personFormatter.getPropertySuffix(firstNameProperty)}</li>
- * <li>{@link DefaultPojoFormatter#getPropertyPrefix(PropertyElement) personFormatter.getPropertyPrefix(lastNameProperty)}</li>
- * <li>{@link DefaultPropertyFormatter#format(Object) lastNameFormatter.format(lastName)}</li>
- * <li>{@link DefaultPojoFormatter#getPropertySuffix(PropertyElement) personFormatter.getPropertySuffix(lasttNameProperty)}</li>
- * <li>{@link DefaultPojoFormatter#getToStringSuffix(Class) personFormatter.getToStringSuffix(Person.class)}</li>
- * </ol>
- * </p>
- *
- * @param instance the instance for which to create a {@code String} representation. Must not be
- * {@code null}.
- * @return the {@code String} representation of the given instance
- */
- public String doToString(T instance) {
- if (instance == null) {
- throw new NullPointerException("instance must not be null");
- }
-
- PojoFormatter pojoFormatter;
- try {
- pojoFormatter = pojoFormatterClass.newInstance();
- }
- catch (InstantiationException e) {
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- StringBuilder result = new StringBuilder();
- result.append(pojoFormatter.getToStringPrefix(clazz));
- for (FormattablePropertyElement formattablePropertyElement: formattablePropertyElements) {
- result.append(pojoFormatter.getPropertyPrefix(formattablePropertyElement.propertyElement));
- result.append(formattablePropertyElement.propertyFormatter.format(
- formattablePropertyElement.propertyElement.getValue(instance)));
- result.append(pojoFormatter.getPropertySuffix(formattablePropertyElement.propertyElement));
- }
- result.append(pojoFormatter.getToStringSuffix(clazz));
- return result.toString();
- }
-
- private final Class<T> clazz;
- private final ClassProperties classProperties;
- private final List<FormattablePropertyElement> formattablePropertyElements =
- new ArrayList<FormattablePropertyElement>();
- private final Class<? extends PojoFormatter> pojoFormatterClass;
-
- private static class FormattablePropertyElement {
- private PropertyElement propertyElement;
- private PropertyFormatter propertyFormatter;
-
- public FormattablePropertyElement(PropertyElement propertyElement,
- PropertyFormatter propertyFormatter) {
- this.propertyElement = propertyElement;
- this.propertyFormatter = propertyFormatter;
- }
- }
-}
Copied: tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java (from rev 82, trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java)
===================================================================
--- tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java (rev 0)
+++ tags/pojomatic-1.0-RC1/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-31 23:24:39 UTC (rev 85)
@@ -0,0 +1,325 @@
+package org.pojomatic.internal;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.pojomatic.Pojomator;
+import org.pojomatic.PropertyElement;
+import org.pojomatic.annotations.PojoFormat;
+import org.pojomatic.annotations.PojomaticPolicy;
+import org.pojomatic.annotations.PropertyFormat;
+import org.pojomatic.formatter.DefaultPojoFormatter;
+import org.pojomatic.formatter.DefaultPropertyFormatter;
+import org.pojomatic.formatter.PojoFormatter;
+import org.pojomatic.formatter.PropertyFormatter;
+
+public class PojomatorImpl<T> implements Pojomator<T>{
+ final static int HASH_CODE_SEED = 1;
+ final static int HASH_CODE_MULTIPLIER = 31;
+
+
+ public PojomatorImpl(Class<T> clazz) {
+ this.clazz = clazz;
+ classProperties = new ClassProperties(clazz);
+ pojoFormatterClass = findPojoFormatterClass(clazz);
+ for (PropertyElement prop: classProperties.getToStringProperties()) {
+ PropertyFormatter propertyFormatter = findPropertyFormatter(prop.getElement());
+ propertyFormatter.initialize(prop.getElement());
+ formattablePropertyElements.add(new FormattablePropertyElement(prop, propertyFormatter));
+ }
+ }
+
+ private static PropertyFormatter findPropertyFormatter(AnnotatedElement element) {
+ PropertyFormat format = element.getAnnotation(PropertyFormat.class);
+ try {
+ return (format == null ? DefaultPropertyFormatter.class : format.value()).newInstance();
+ }
+ catch (InstantiationException e) {
+ //TODO log this?
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e) {
+ //TODO log this?
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Class<? extends PojoFormatter> findPojoFormatterClass(Class<?> clazz) {
+ PojoFormat format = clazz.getAnnotation(PojoFormat.class);
+ return format == null ? DefaultPojoFormatter.class : format.value();
+ }
+
+ /**
+ * {@inheritDoc}
+ *<p>
+ * For this to return true, the following must hold:
+ * <ul>
+ * <li>{@code other} must be non-null, and an instance of {@code T}</li>
+ * <li>Each property of {@code instance} which has a {@link PojomaticPolicy} other than
+ * {@link PojomaticPolicy#TO_STRING TO_STRING} or {@link PojomaticPolicy#NONE NONE} must be equal
+ * to the corresponding property of {@code other} in the following sense:
+ * <ul>
+ * <li>Both are {@code null}, or</li>
+ * <li>Both are reference-equals (==) to each other, or</li>
+ * <li>Both are primitive of the same type, and equal to each other, or</li>
+ * <li>Both are of array type, with matching primitive component types, and the corresponding
+ * {@code} equals method of {@link Arrays} returns true, or</li>
+ * <li>Both are of array type with non-primitive component types, and
+ * {@link Arrays#deepEquals(Object[], Object[])} returns true, or</li>
+ * <li>The property {@code p} in {@code instance} is an object not of array type, and
+ * {@code instanceP.equals(otherP)} returns true.
+ * </ul>
+ * </ul>
+ *
+ * @throws NullPointerException if {@code instance} is null
+ */
+ public boolean doEquals(T instance, Object other) {
+ if (instance == null) {
+ throw new NullPointerException("instance must not be null");
+ }
+ if (instance == other) {
+ return true;
+ }
+ if (! clazz.isInstance(other)) {
+ return false;
+ }
+
+ for (PropertyElement prop: classProperties.getEqualsProperties()) {
+ Object instanceValue = prop.getValue(instance);
+ Object otherValue = prop.getValue(other);
+ if (instanceValue == null) {
+ if (otherValue != null) {
+ return false;
+ }
+ }
+ else { // instanceValue is not null
+ if (otherValue == null) {
+ return false;
+ }
+ if (!instanceValue.getClass().isArray()) {
+ if (!instanceValue.equals(otherValue)) {
+ return false;
+ }
+ }
+ else {
+ if (!otherValue.getClass().isArray()) {
+ return false;
+ }
+ Class<?> instanceComponentClass = instanceValue.getClass().getComponentType();
+ Class<?> otherComponentClass = otherValue.getClass().getComponentType();
+
+ if (!instanceComponentClass.isPrimitive()) {
+ if (otherComponentClass.isPrimitive()) {
+ return false;
+ }
+ if (!Arrays.deepEquals((Object[]) instanceValue, (Object[]) otherValue)) {
+ return false;
+ }
+ }
+ else { // instanceComponentClass is primative
+ if (otherComponentClass != instanceComponentClass) {
+ return false;
+ }
+
+ if (Boolean.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((boolean[]) instanceValue, (boolean[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Byte.TYPE == instanceComponentClass) {
+ if (! Arrays.equals((byte[]) instanceValue, (byte[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Character.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((char[]) instanceValue, (char[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Short.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((short[]) instanceValue, (short[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Integer.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((int[]) instanceValue, (int[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Long.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((long[]) instanceValue, (long[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Float.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((float[]) instanceValue, (float[]) otherValue)) {
+ return false;
+ }
+ }
+ else if (Double.TYPE == instanceComponentClass) {
+ if(!Arrays.equals((double[]) instanceValue, (double[]) otherValue)) {
+ return false;
+ }
+ }
+ else {
+ // should NEVER happen
+ throw new IllegalStateException(
+ "unknown primative type " + instanceComponentClass.getName());
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *<p>
+ * This is done by computing the hashCode of each property which has a {@link PojomaticPolicy} of
+ * {@link PojomaticPolicy#HASHCODE_EQUALS HASHCODE_EQUALS} or {@link PojomaticPolicy#ALL ALL}
+ * (using 0 when the property is null), and combining them in a fashion similar to that of
+ * {@link List#hashCode()}.
+ *
+ * @throws NullPointerException if {@code instance} is null
+ */
+ public int doHashCode(T instance) {
+ int hashCode = HASH_CODE_SEED;
+ if (instance == null) {
+ throw new NullPointerException("instance must not be null");
+ }
+ for (PropertyElement prop: classProperties.getHashCodeProperties()) {
+ Object value = prop.getValue(instance);
+ hashCode = HASH_CODE_MULTIPLIER * hashCode + (hashCodeOfValue(value));
+ }
+ return hashCode;
+ }
+
+ private int hashCodeOfValue(Object value) {
+ if (value == null) {
+ return 0;
+ }
+ else {
+ if (value.getClass().isArray()) {
+ Class<?> instanceComponentClass = value.getClass().getComponentType();
+ if (! instanceComponentClass.isPrimitive()) {
+ return Arrays.hashCode((Object[]) value);
+ }
+ else {
+ if (Boolean.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((boolean[]) value);
+ }
+ else if (Byte.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((byte[]) value);
+ }
+ else if (Character.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((char[]) value);
+ }
+ else if (Short.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((short[]) value);
+ }
+ else if (Integer.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((int[]) value);
+ }
+ else if (Long.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((long[]) value);
+ }
+ else if (Float.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((float[]) value);
+ }
+ else if (Double.TYPE == instanceComponentClass) {
+ return Arrays.hashCode((double[]) value);
+ }
+ else {
+ // should NEVER happen
+ throw new IllegalStateException(
+ "unknown primative type " + instanceComponentClass.getName());
+ }
+ }
+ }
+ else {
+ return value.hashCode();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * The format used depends on the
+ * {@link PojoFormatter} used for the POJO, and the {@link PropertyFormatter} of each property.
+ * <p>
+ * For example, suppose a class {@code Person} has properties {@code firstName} and
+ * {@code lastName} which are included in its {@code String} representation.
+ * No {@code PojoFormatter} or {@code PropertyFormatter} are specified, so the defaults are used.
+ * In particular, instances of {@code DefaultPropertyFormatter} will be created for
+ * {@code firstName} and {@code lastName} (referred to here as {@code firstNameFormatter} and
+ * {@code lastNameFormatter}, respectively). Let {@code firstNameProperty} and
+ * {@code lastNameProperty} refer to the instances of {@link PropertyElement} referring to the
+ * properties {@code firstName} and {@code lastName} respectively.
+ * </p>
+ * <p>
+ * For a non-null {@code Person} instance, the {@code String} representation will be created by
+ * creating an instance of {@code DefaultPojoFormatter} for the {@code Person} class (referred to
+ * here as {@code personFormatter}), and then concatenating the results of following:
+ * <ol>
+ * <li>{@link DefaultPojoFormatter#getToStringPrefix(Class) personFormatter.getToStringPrefix(Person.class)}</li>
+ * <li>{@link DefaultPojoFormatter#getPropertyPrefix(PropertyElement) personFormatter.getPropertyPrefix(f...
[truncated message content] |
|
From: <iro...@us...> - 2008-12-31 23:24:17
|
Revision: 84
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=84&view=rev
Author: iroberts
Date: 2008-12-31 23:24:15 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
[maven-release-plugin] prepare release pojomatic-1.0-RC1
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-12-31 23:09:38 UTC (rev 83)
+++ trunk/Pojomatic/pom.xml 2008-12-31 23:24:15 UTC (rev 84)
@@ -3,7 +3,7 @@
<groupId>org.pojomatic</groupId>
<artifactId>pojomatic</artifactId>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>1.0-RC1</version>
<name>Pojomatic</name>
<description>
Automatically provides configurable implementations of the
@@ -12,9 +12,9 @@
<url>http://www.pojomatic.org</url>
<inceptionYear>2008</inceptionYear>
<scm>
- <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</connection>
- <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</developerConnection>
- <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</url>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-1.0-RC1</url>
</scm>
<developers>
<developer>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-31 23:09:40
|
Revision: 83
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=83&view=rev
Author: iroberts
Date: 2008-12-31 23:09:38 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
remove unneeded method
Modified Paths:
--------------
trunk/Pojomatic/src/test/java/examples/Auto.java
Modified: trunk/Pojomatic/src/test/java/examples/Auto.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/Auto.java 2008-12-31 23:04:40 UTC (rev 82)
+++ trunk/Pojomatic/src/test/java/examples/Auto.java 2008-12-31 23:09:38 UTC (rev 83)
@@ -31,13 +31,8 @@
return Pojomatic.equals(this, o);
}
- public boolean isEmpty() {
- //TODO
- return false;
- }
-
public boolean isTest() {
- return this.test;
+ return test;
}
public void setTest(boolean test) {
@@ -45,7 +40,7 @@
}
public int getExlude() {
- return this.exlude;
+ return exlude;
}
public void setExlude(int exlude) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-31 23:04:43
|
Revision: 82
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=82&view=rev
Author: iroberts
Date: 2008-12-31 23:04:40 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
Beef up javadoc
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-31 22:29:58 UTC (rev 81)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-31 23:04:40 UTC (rev 82)
@@ -8,6 +8,7 @@
import org.pojomatic.Pojomator;
import org.pojomatic.PropertyElement;
import org.pojomatic.annotations.PojoFormat;
+import org.pojomatic.annotations.PojomaticPolicy;
import org.pojomatic.annotations.PropertyFormat;
import org.pojomatic.formatter.DefaultPojoFormatter;
import org.pojomatic.formatter.DefaultPropertyFormatter;
@@ -50,6 +51,30 @@
return format == null ? DefaultPojoFormatter.class : format.value();
}
+ /**
+ * {@inheritDoc}
+ *<p>
+ * For this to return true, the following must hold:
+ * <ul>
+ * <li>{@code other} must be non-null, and an instance of {@code T}</li>
+ * <li>Each property of {@code instance} which has a {@link PojomaticPolicy} other than
+ * {@link PojomaticPolicy#TO_STRING TO_STRING} or {@link PojomaticPolicy#NONE NONE} must be equal
+ * to the corresponding property of {@code other} in the following sense:
+ * <ul>
+ * <li>Both are {@code null}, or</li>
+ * <li>Both are reference-equals (==) to each other, or</li>
+ * <li>Both are primitive of the same type, and equal to each other, or</li>
+ * <li>Both are of array type, with matching primitive component types, and the corresponding
+ * {@code} equals method of {@link Arrays} returns true, or</li>
+ * <li>Both are of array type with non-primitive component types, and
+ * {@link Arrays#deepEquals(Object[], Object[])} returns true, or</li>
+ * <li>The property {@code p} in {@code instance} is an object not of array type, and
+ * {@code instanceP.equals(otherP)} returns true.
+ * </ul>
+ * </ul>
+ *
+ * @throws NullPointerException if {@code instance} is null
+ */
public boolean doEquals(T instance, Object other) {
if (instance == null) {
throw new NullPointerException("instance must not be null");
@@ -82,8 +107,6 @@
if (!otherValue.getClass().isArray()) {
return false;
}
- //TODO - decide if we should choose to enter this branch based off of the property's
- // declared or runtime type. Either way, document the choice. For now, runtime.
Class<?> instanceComponentClass = instanceValue.getClass().getComponentType();
Class<?> otherComponentClass = otherValue.getClass().getComponentType();
@@ -152,6 +175,16 @@
return true;
}
+ /**
+ * {@inheritDoc}
+ *<p>
+ * This is done by computing the hashCode of each property which has a {@link PojomaticPolicy} of
+ * {@link PojomaticPolicy#HASHCODE_EQUALS HASHCODE_EQUALS} or {@link PojomaticPolicy#ALL ALL}
+ * (using 0 when the property is null), and combining them in a fashion similar to that of
+ * {@link List#hashCode()}.
+ *
+ * @throws NullPointerException if {@code instance} is null
+ */
public int doHashCode(T instance) {
int hashCode = HASH_CODE_SEED;
if (instance == null) {
@@ -213,7 +246,9 @@
}
/**
- * Creates the {@code String} representation of the given instance. The format used depends on the
+ * {@inheritDoc}
+ * <p>
+ * The format used depends on the
* {@link PojoFormatter} used for the POJO, and the {@link PropertyFormatter} of each property.
* <p>
* For example, suppose a class {@code Person} has properties {@code firstName} and
@@ -241,9 +276,7 @@
* </ol>
* </p>
*
- * @param instance the instance for which to create a {@code String} representation. Must not be
- * {@code null}.
- * @return the {@code String} representation of the given instance
+ * @throws NullPointerException if {@code instance} is null
*/
public String doToString(T instance) {
if (instance == null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-31 22:30:03
|
Revision: 81
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=81&view=rev
Author: iroberts
Date: 2008-12-31 22:29:58 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java 2008-12-17 23:09:51 UTC (rev 80)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPojoFormatter.java 2008-12-31 22:29:58 UTC (rev 81)
@@ -4,9 +4,14 @@
import org.pojomatic.PropertyElement;
/**
- * Default formatter for classes that use {@link Pojomatic}.
- * For example,
- * TODO provide an example
+ * Default formatter for classes that use {@link Pojomatic}. This implementation first presents
+ * the class name, and then each property in turn, separated by commas, using braces to indicate
+ * nesting.
+ * <p>
+ * For example, if a class Person has two properties, firstName and LastName, and these properties
+ * are using {@link DefaultPropertyFormatter}, then the Person
+ * instance representing Joe Blow would be represented as
+ * <code>"Person{firstName: {Joe}, lastName: {Blow}}"</code>
*/
public class DefaultPojoFormatter implements PojoFormatter {
private boolean firstPropertyPrinted = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-17 23:09:55
|
Revision: 80
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=80&view=rev
Author: iroberts
Date: 2008-12-17 23:09:51 +0000 (Wed, 17 Dec 2008)
Log Message:
-----------
deploy straight to the top
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-12-17 23:07:56 UTC (rev 79)
+++ trunk/Pojomatic/pom.xml 2008-12-17 23:09:51 UTC (rev 80)
@@ -66,7 +66,7 @@
<id>pojomatic-site</id>
<name>Pojomatic</name>
<!-- before deploying, you'll need to run ssh <username>,poj...@sh... create -->
- <url>scp://shell.sourceforge.net/home/groups/p/po/pojomatic/htdocs/site</url>
+ <url>scp://shell.sourceforge.net/home/groups/p/po/pojomatic/htdocs</url>
</site>
</distributionManagement>
<mailingLists>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-17 23:07:58
|
Revision: 79
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=79&view=rev
Author: iroberts
Date: 2008-12-17 23:07:56 +0000 (Wed, 17 Dec 2008)
Log Message:
-----------
Get site deploy working
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-12-09 02:26:14 UTC (rev 78)
+++ trunk/Pojomatic/pom.xml 2008-12-17 23:07:56 UTC (rev 79)
@@ -65,7 +65,8 @@
<site>
<id>pojomatic-site</id>
<name>Pojomatic</name>
- <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/htdocs/site</url>
+ <!-- before deploying, you'll need to run ssh <username>,poj...@sh... create -->
+ <url>scp://shell.sourceforge.net/home/groups/p/po/pojomatic/htdocs/site</url>
</site>
</distributionManagement>
<mailingLists>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-09 02:26:18
|
Revision: 78
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=78&view=rev
Author: iroberts
Date: 2008-12-09 02:26:14 +0000 (Tue, 09 Dec 2008)
Log Message:
-----------
prettify the site
Added Paths:
-----------
trunk/Pojomatic/src/site/resources/
trunk/Pojomatic/src/site/resources/css/
trunk/Pojomatic/src/site/resources/css/site.css
trunk/Pojomatic/src/site/site.xml
Added: trunk/Pojomatic/src/site/resources/css/site.css
===================================================================
--- trunk/Pojomatic/src/site/resources/css/site.css (rev 0)
+++ trunk/Pojomatic/src/site/resources/css/site.css 2008-12-09 02:26:14 UTC (rev 78)
@@ -0,0 +1,4 @@
+.source {
+ border: 1px solid #999;
+ background-color: #eeeeff
+}
Property changes on: trunk/Pojomatic/src/site/resources/css/site.css
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/Pojomatic/src/site/site.xml
===================================================================
--- trunk/Pojomatic/src/site/site.xml (rev 0)
+++ trunk/Pojomatic/src/site/site.xml 2008-12-09 02:26:14 UTC (rev 78)
@@ -0,0 +1,8 @@
+<project>
+ <body>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ </menu>
+ <menu ref="reports"/>
+ </body>
+</project>
Property changes on: trunk/Pojomatic/src/site/site.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-08 23:58:23
|
Revision: 77
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=77&view=rev
Author: iroberts
Date: 2008-12-08 23:58:20 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
More information, for those so inclined.
Modified Paths:
--------------
trunk/Pojomatic/src/site/apt/index.apt
Modified: trunk/Pojomatic/src/site/apt/index.apt
===================================================================
--- trunk/Pojomatic/src/site/apt/index.apt 2008-12-08 23:37:06 UTC (rev 76)
+++ trunk/Pojomatic/src/site/apt/index.apt 2008-12-08 23:58:20 UTC (rev 77)
@@ -56,3 +56,5 @@
--------
Person{firstName: {John}, lastName: {Doe}, age: {32}}
--------
+
+ For more information, see the {{{apidocs/index.html}JavaDocs}}.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-08 23:37:10
|
Revision: 76
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=76&view=rev
Author: iroberts
Date: 2008-12-08 23:37:06 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
Finish up javadoc
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java
trunk/Pojomatic/src/main/java/org/pojomatic/formatter/PojoFormatter.java
trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
trunk/Pojomatic/src/main/javadoc/overview.html
Added Paths:
-----------
trunk/Pojomatic/src/test/java/examples/Customer.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2008-12-08 23:36:26 UTC (rev 75)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/Pojomatic.java 2008-12-08 23:37:06 UTC (rev 76)
@@ -4,25 +4,48 @@
import org.pojomatic.internal.SelfPopulatingMap;
/**
- * Static convenience methods for working with {@code Pojomator}s. This class is carefull to create
- * only a single {@code Pojomator} per pojo class. The overhead for looking up the {@code Pojomator}
- * by pojo class is light, so a a typical use in a pojo class would be
- * <p>
+ * Static methods for implementing the {@link java.lang.Object#equals(Object)},
+ * {@link java.lang.Object#hashCode()} and {@link java.lang.Object#toString()} methods on a
+ * annotated POJO. The actual work for a given class is done by a {@link Pojomator} created for
+ * that class. This class is careful to create only a single {@code Pojomator} per POJO class.
+ * The overhead for looking up the {@code Pojomator} by POJO class is light, so a typical use in a
+ * POJO class would be
+ * <p style="background-color:#EEEEFF; margin: 1em">
* <code>
* <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode() {</font><br>
- * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomator.hashCode(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
+ * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.hashCode(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
* <font color="#000000">}</font><br>
* <br/>
* <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals(Object other) {</font><br>
- * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomator.equals(</font><font color="#7f0055"><b>this</b></font><font color="#000000">, other);</font><br />
+ * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.equals(</font><font color="#7f0055"><b>this</b></font><font color="#000000">, other);</font><br />
* <font color="#000000">}</font><br>
* <br/>
* <font color="#646464">@Override</font> <font color="#7f0055"><b>public </b></font><font color="#000000">String toString() {</font><br>
- * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomator.toString(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
+ * <font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.toString(</font><font color="#7f0055"><b>this</b></font><font color="#000000">);</font><br />
* <font color="#000000">}</font><br>
* <br/>
* </code>
* </p>
+ * Under the covers, these methods are referencing a {@link org.pojomatic.Pojomator Pojomator} instance
+ * which is created lazily and cached on a per-class basis. The performance penalty for this is
+ * negligible, but if profiling suggests that it is a bottleneck, one can do this by hand:
+ * <p style="background-color:#EEEEFF; margin: 1em">
+ * <code>
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>private final static </b></font><font color="#000000">Pojomator<Manual> POJOMATOR = Pojomatic.pojomator</font><font color="#000000">(</font><font color="#000000">Manual.</font><font color="#7f0055"><b>class</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"></font><br />
+ * <font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object other</font><font color="#000000">) {</font><br />
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doEquals</font><font color="#000000">(</font><font color="#000000">this, other</font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"> </font><font color="#000000">}</font><br />
+ * <font color="#ffffff"></font><br />
+ * <font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doHashCode</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"> </font><font color="#000000">}</font><br />
+ * <font color="#ffffff"></font><br />
+ * <font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#000000">String toString</font><font color="#000000">() {</font><br />
+ * <font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doToString</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+ * <font color="#ffffff"> </font><font color="#000000">}</font>
+ * </code>
+ * </p>
*
* @see Pojomator
*/
@@ -42,9 +65,9 @@
private Pojomatic() {}
/**
- * Compute the {@code toString} representation for a pojo.
- * @param <T> the type of the pojo
- * @param pojo the pojo - must not be null
+ * Compute the {@code toString} representation for a POJO.
+ * @param <T> the type of the POJO
+ * @param pojo the POJO - must not be null
* @return the {@code toString} representation of {@code pojo}.
* @see Pojomator#doToString(Object)
*/
@@ -53,9 +76,9 @@
}
/**
- * Compute the {@code hashCode} for a pojo.
- * @param <T> the type of the pojo
- * @param pojo the pojo - must not be null
+ * Compute the {@code hashCode} for a POJO.
+ * @param <T> the type of the POJO
+ * @param pojo the POJO - must not be null
* @return the {@code hashCode} for {@code pojo}.
* @see Pojomator#doHashCode(Object)
*/
@@ -66,8 +89,8 @@
/**
* Compute whether {@code pojo} and {@code other} are equal to each other in the sense of
* {@code Object}'s {@code equals} method.
- * @param <T> the type of the pojo
- * @param pojo the pojo - must not be null
+ * @param <T> the type of the POJO
+ * @param pojo the POJO - must not be null
* @param other the object to compare to for equality
* @return whether {@code pojo} and {@code other} are equal to each other in the sense of
* {@code Object}'s {@code equals} method.
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/formatter/PojoFormatter.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/formatter/PojoFormatter.java 2008-12-08 23:36:26 UTC (rev 75)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/formatter/PojoFormatter.java 2008-12-08 23:37:06 UTC (rev 76)
@@ -4,7 +4,7 @@
import org.pojomatic.internal.PojomatorImpl;
/**
- * A formatter to aid in creating a {@code String} representation of a Pojo. A new instance will be
+ * A formatter to aid in creating a {@code String} representation of a POJO. A new instance will be
* created for each time that {@link PojomatorImpl#doToString(Object)} is called.
*
* @see PojomatorImpl#doToString(Object)
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-08 23:36:26 UTC (rev 75)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/internal/PojomatorImpl.java 2008-12-08 23:37:06 UTC (rev 76)
@@ -214,7 +214,7 @@
/**
* Creates the {@code String} representation of the given instance. The format used depends on the
- * {@link PojoFormatter} used for the pojo, and the {@link PropertyFormatter} of each property.
+ * {@link PojoFormatter} used for the POJO, and the {@link PropertyFormatter} of each property.
* <p>
* For example, suppose a class {@code Person} has properties {@code firstName} and
* {@code lastName} which are included in its {@code String} representation.
Modified: trunk/Pojomatic/src/main/javadoc/overview.html
===================================================================
--- trunk/Pojomatic/src/main/javadoc/overview.html 2008-12-08 23:36:26 UTC (rev 75)
+++ trunk/Pojomatic/src/main/javadoc/overview.html 2008-12-08 23:37:06 UTC (rev 76)
@@ -7,10 +7,11 @@
<title>Overview</title>
</head>
<body>
-Pojomatic is a library which allows simple creation of the three methods
+Pojomatic is a library which allows simple implementation of the three methods
{@link java.lang.Object#equals(Object)}, {@link java.lang.Object#hashCode()} and
{@link java.lang.Object#toString()} by
-annotating properties. There are two steps to "pojomate" a pojo class: annotating, and implementing
+annotating properties on a Plain Old Java Object, or POJO.
+There are two steps to "pojomate" a POJO class: annotating, and implementing
the three methods.
<h2>Annotations</h2>
@@ -19,14 +20,15 @@
{@link org.pojomatic.annotations.AutoProperty AutoProperty} and
{@link org.pojomatic.annotations.PojoFormat PojoFormat}, while property-specific behavior can be
controlled by the {@link org.pojomatic.annotations.Property Property} and
-{@link org.pojomatic.annotations.PojoFormat PropertyFormat} annotations. A recommended practice is
+{@link org.pojomatic.annotations.PropertyFormat PropertyFormat} annotations. A recommended practice is
to provide an {@code AutoProperty} annotation at the class level, and then override the behavior it
specifies on a per-property basis as needed. This minimizes both the number of annotations needed,
as well as the number of additional steps needed when adding new properties to a class.
<h2>Implementing equals, hashCode and toString</h2>
-There are two ways to implement equals, hashCode and toString. The simplest is to delegate to the
-static methods in {@link org.pojomatic.Pojomatic Pojomatic}:
+To implement equals, hashCode and toString, simply annotate the class for pojomation (see below),
+and delegate to the static methods in
+{@link org.pojomatic.Pojomatic Pojomatic}:
<p style="background-color:#EEEEFF; margin: 1em">
<code>
<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
@@ -41,28 +43,7 @@
<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.equals</font><font color="#000000">(</font><font color="#000000">this, o</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font></code>
</p>
-Under the covers, these methods are referencing a {@link org.pojomatic.Pojomator Pojomator} instance
-which is created lazily and cached on a per-class basis. The performance penalty for this is
-negligible, but if profiling suggests that it is a bottleneck, one can do this by hand:
-<p style="background-color:#EEEEFF; margin: 1em">
-<code>
-<font color="#ffffff"> </font><font color="#7f0055"><b>private final static </b></font><font color="#000000">Pojomator<Manual> POJOMATOR = Pojomatic.pojomator</font><font color="#000000">(</font><font color="#000000">Manual.</font><font color="#7f0055"><b>class</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"></font><br />
-<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object other</font><font color="#000000">) {</font><br />
-<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doEquals</font><font color="#000000">(</font><font color="#000000">this, other</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">}</font><br />
-<font color="#ffffff"></font><br />
-<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
-<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doHashCode</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">}</font><br />
-<font color="#ffffff"></font><br />
-<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#000000">String toString</font><font color="#000000">() {</font><br />
-<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doToString</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">}</font>
-</code>
-</p>
-
<h2>Example Annotations</h2>
The simplest way to annotate a class for pojomation is to add a single {@code AutoProperty} annotation:
@@ -76,17 +57,18 @@
</p>
If you wish reference properties by getter methods instead of direct field access, you can do this by
-passing {@code autoDetect=AutoDetectPolicy.METHOD} to the {@code AutoProperty} annotation.
-
+passing {@code autoDetect=AutoDetectPolicy.METHOD} to the
+{@link org.pojomatic.annotations.AutoProperty AutoProperty} annotation.
By default, all properties are used in the implementations of the {@code equals}, {@code hashCode}
and {@code toString} methods; this can be changed via the
-{@link org.pojomatic.annotations.AutoProperty#policy policy} parameter to {@code AutoProperty}.
-Additionally, one can override this choice on a per-property basis by use of the {@code Property}
+{@link org.pojomatic.annotations.AutoProperty#policy policy} parameter to
+{@link org.pojomatic.annotations.AutoProperty AutoProperty}.
+Additionally, one can override this choice on a per-property basis by use of the
+{@link org.pojomatic.annotations.Property Property}
annotation. For example, if you have a class with a mutable field which you do not wish to include
in the {@code hashCode} calculation, you can accomplish this via:
-
-<p style="background-color:#EEEEFF; margin: 1em">
+<p style="background-color:#EEEEFF; margin: 1em">
<code>
<font color="#646464">@AutoProperty</font><br />
<font color="#7f0055"><b>public class </b></font><font color="#000000">Employee </font><font color="#000000">{</font><br />
@@ -100,5 +82,53 @@
</code>
</p>
+The {@code toString} implementation provided by Pojomatic defaults to using
+{@link org.pojomatic.formatter.DefaultPojoFormatter DefaultPojoFormatter}; you can specify your
+own formatting by providing an alternate implementation of
+{@link org.pojomatic.formatter.PojoFormatter PojoFormatter} and using the
+{@link org.pojomatic.annotations.PojoFormat PojoFormat} annotation. In addition to controling the
+overall format of {@code toString}, the formatting of individual properties can be controlled by
+a {@link org.pojomatic.annotations.PropertyFormat PropertyFormat} annotation referencing an
+implementation of {@link org.pojomatic.formatter.PropertyFormatter PropertyFormatter}. In addition
+to {@link org.pojomatic.formatter.DefaultPropertyFormatter DefaultPropertyFormatter}, this library
+also provides an {@link org.pojomatic.formatter.AccountNumberFormatter AccountNumberFormatter} for
+formatting properties with sensitive data.
+
+Taking all of this together, a Customer POJO using pojomatic might look like:
+
+<p style="background-color:#EEEEFF; margin: 1em">
+<code>
+<font color="#646464">@AutoProperty</font><br />
+<font color="#7f0055"><b>public class </b></font><font color="#000000">Customer </font><font color="#000000">{</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>private final </b></font><font color="#000000">String firstName;</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>private final </b></font><font color="#000000">String lastName;</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@PropertyFormat</font><font color="#000000">(</font><font color="#000000">AccountNumberFormatter.</font><font color="#7f0055"><b>class</b></font><font color="#000000">)</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>private final </b></font><font color="#000000">String accountNumber;</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">Customer</font><font color="#000000">(</font><font color="#000000">String accountNumber, String firstName, String lastName</font><font color="#000000">) {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>this</b></font><font color="#000000">.accountNumber = accountNumber;</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>this</b></font><font color="#000000">.firstName = firstName;</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>this</b></font><font color="#000000">.lastName = lastName;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">String getFirstName</font><font color="#000000">() { </font><font color="#7f0055"><b>return </b></font><font color="#000000">firstName; </font><font color="#000000">}</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">String getLastName</font><font color="#000000">() { </font><font color="#7f0055"><b>return </b></font><font color="#000000">lastName; </font><font color="#000000">}</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">String getAccountNumber</font><font color="#000000">() { </font><font color="#7f0055"><b>return </b></font><font color="#000000">accountNumber; </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.hashCode</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#000000">String toString</font><font color="#000000">() {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.toString</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object o</font><font color="#000000">) {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.equals</font><font color="#000000">(</font><font color="#000000">this, o</font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#000000">}</font></code>
+</p>
</body>
</html>
Added: trunk/Pojomatic/src/test/java/examples/Customer.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/Customer.java (rev 0)
+++ trunk/Pojomatic/src/test/java/examples/Customer.java 2008-12-08 23:37:06 UTC (rev 76)
@@ -0,0 +1,42 @@
+package examples;
+
+import org.pojomatic.Pojomatic;
+import org.pojomatic.annotations.AutoProperty;
+import org.pojomatic.annotations.PropertyFormat;
+import org.pojomatic.formatter.AccountNumberFormatter;
+
+@AutoProperty
+public class Customer {
+ private final String firstName;
+
+ private final String lastName;
+
+ @PropertyFormat(AccountNumberFormatter.class)
+ private final String accountNumber;
+
+ public Customer(String accountNumber, String firstName, String lastName) {
+ this.accountNumber = accountNumber;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public String getFirstName() { return firstName; }
+ public String getLastName() { return lastName; }
+ public String getAccountNumber() { return accountNumber; }
+
+ @Override public int hashCode() {
+ return Pojomatic.hashCode(this);
+ }
+
+ @Override public String toString() {
+ return Pojomatic.toString(this);
+ }
+
+ @Override public boolean equals(Object o) {
+ return Pojomatic.equals(this, o);
+ }
+
+ public static void main(String[] args) {
+ System.out.println(new Customer("12345", "Joe", "Blow"));
+ }
+}
Property changes on: trunk/Pojomatic/src/test/java/examples/Customer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-08 23:36:35
|
Revision: 75
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=75&view=rev
Author: iroberts
Date: 2008-12-08 23:36:26 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
Note that a PropertyFormat annotation does not guarantee inclusion in toString
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PropertyFormat.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PropertyFormat.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PropertyFormat.java 2008-12-02 18:09:19 UTC (rev 74)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PropertyFormat.java 2008-12-08 23:36:26 UTC (rev 75)
@@ -11,7 +11,10 @@
import org.pojomatic.formatter.PropertyFormatter;
/**
- * Specifies formatting information to be used for creating {@code String} representations of properties.
+ * Specifies formatting information to be used for creating {@code String} representations of
+ * properties. Note that using a {@code PropertyFormat} annotation on a property does not influence
+ * whether that property will be included in the {@code toString} implementation. That is
+ * determined solely by any {@link Property} and {@link AutoProperty} annotations on the POJO.
* @see PropertyFormatter
*/
@Target({FIELD, METHOD})
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-02 18:09:22
|
Revision: 74
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=74&view=rev
Author: iroberts
Date: 2008-12-02 18:09:19 +0000 (Tue, 02 Dec 2008)
Log Message:
-----------
more overview javadoc
Modified Paths:
--------------
trunk/Pojomatic/src/main/javadoc/overview.html
Added Paths:
-----------
trunk/Pojomatic/src/test/java/examples/Employee.java
trunk/Pojomatic/src/test/java/examples/GetterAccess.java
trunk/Pojomatic/src/test/java/examples/Manual.java
Modified: trunk/Pojomatic/src/main/javadoc/overview.html
===================================================================
--- trunk/Pojomatic/src/main/javadoc/overview.html 2008-12-02 18:08:46 UTC (rev 73)
+++ trunk/Pojomatic/src/main/javadoc/overview.html 2008-12-02 18:09:19 UTC (rev 74)
@@ -8,8 +8,9 @@
</head>
<body>
Pojomatic is a library which allows simple creation of the three methods
-{@link Object#equals(Object)}, {@link Object#hashCode()} and {@link Object#toString()} by
-annotating properties. There are two steps to pojomatize a pojo class: annotating, and implementing
+{@link java.lang.Object#equals(Object)}, {@link java.lang.Object#hashCode()} and
+ {@link java.lang.Object#toString()} by
+annotating properties. There are two steps to "pojomate" a pojo class: annotating, and implementing
the three methods.
<h2>Annotations</h2>
@@ -19,8 +20,85 @@
{@link org.pojomatic.annotations.PojoFormat PojoFormat}, while property-specific behavior can be
controlled by the {@link org.pojomatic.annotations.Property Property} and
{@link org.pojomatic.annotations.PojoFormat PropertyFormat} annotations. A recommended practice is
-to provide an {@code AutoProperty} annotation at the class level, and the override the behavior it
+to provide an {@code AutoProperty} annotation at the class level, and then override the behavior it
specifies on a per-property basis as needed. This minimizes both the number of annotations needed,
as well as the number of additional steps needed when adding new properties to a class.
+
+<h2>Implementing equals, hashCode and toString</h2>
+There are two ways to implement equals, hashCode and toString. The simplest is to delegate to the
+static methods in {@link org.pojomatic.Pojomatic Pojomatic}:
+<p style="background-color:#EEEEFF; margin: 1em">
+<code>
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.hashCode</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#000000">String toString</font><font color="#000000">() {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.toString</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object o</font><font color="#000000">) {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">Pojomatic.equals</font><font color="#000000">(</font><font color="#000000">this, o</font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font></code>
+</p>
+Under the covers, these methods are referencing a {@link org.pojomatic.Pojomator Pojomator} instance
+which is created lazily and cached on a per-class basis. The performance penalty for this is
+negligible, but if profiling suggests that it is a bottleneck, one can do this by hand:
+
+<p style="background-color:#EEEEFF; margin: 1em">
+<code>
+<font color="#ffffff"> </font><font color="#7f0055"><b>private final static </b></font><font color="#000000">Pojomator<Manual> POJOMATOR = Pojomatic.pojomator</font><font color="#000000">(</font><font color="#000000">Manual.</font><font color="#7f0055"><b>class</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>boolean </b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object other</font><font color="#000000">) {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doEquals</font><font color="#000000">(</font><font color="#000000">this, other</font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">hashCode</font><font color="#000000">() {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doHashCode</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Override </font><font color="#7f0055"><b>public </b></font><font color="#000000">String toString</font><font color="#000000">() {</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">POJOMATOR.doToString</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
+<font color="#ffffff"> </font><font color="#000000">}</font>
+</code>
+</p>
+
+<h2>Example Annotations</h2>
+The simplest way to annotate a class for pojomation is to add a single {@code AutoProperty} annotation:
+
+<p style="background-color:#EEEEFF; margin: 1em">
+<code>
+<font color="#646464">@AutoProperty </font><font color="#3f7f5f">//all fields are included by default</font><br />
+<font color="#7f0055"><b>public class </b></font><font color="#000000">Common </font><font color="#000000">{</font><br />
+ ...<br />
+}<br />
+</code>
+</p>
+
+If you wish reference properties by getter methods instead of direct field access, you can do this by
+passing {@code autoDetect=AutoDetectPolicy.METHOD} to the {@code AutoProperty} annotation.
+
+By default, all properties are used in the implementations of the {@code equals}, {@code hashCode}
+and {@code toString} methods; this can be changed via the
+{@link org.pojomatic.annotations.AutoProperty#policy policy} parameter to {@code AutoProperty}.
+Additionally, one can override this choice on a per-property basis by use of the {@code Property}
+annotation. For example, if you have a class with a mutable field which you do not wish to include
+in the {@code hashCode} calculation, you can accomplish this via:
+
+
+<p style="background-color:#EEEEFF; margin: 1em">
+<code>
+<font color="#646464">@AutoProperty</font><br />
+<font color="#7f0055"><b>public class </b></font><font color="#000000">Employee </font><font color="#000000">{</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>private final </b></font><font color="#000000">String firstName;</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>private final </b></font><font color="#000000">String lastName;</font><br />
+<font color="#ffffff"></font><br />
+<font color="#ffffff"> </font><font color="#646464">@Property</font><font color="#000000">(</font><font color="#000000">policy=PojomaticPolicy.EQUALS_TO_STRING</font><font color="#000000">)</font><br />
+<font color="#ffffff"> </font><font color="#7f0055"><b>private </b></font><font color="#000000">String securityLevel;</font><br />
+ ...<br />
+}<br />
+</code>
+</p>
+
</body>
</html>
Added: trunk/Pojomatic/src/test/java/examples/Employee.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/Employee.java (rev 0)
+++ trunk/Pojomatic/src/test/java/examples/Employee.java 2008-12-02 18:09:19 UTC (rev 74)
@@ -0,0 +1,39 @@
+package examples;
+
+import org.pojomatic.annotations.AutoProperty;
+import org.pojomatic.annotations.PojomaticPolicy;
+import org.pojomatic.annotations.Property;
+
+@AutoProperty
+public class Employee {
+ private final String firstName;
+ private final String lastName;
+
+ @Property(policy=PojomaticPolicy.EQUALS_TO_STRING)
+ private String securityLevel;
+
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+
+ public String getSecurityLevel() {
+ return this.securityLevel;
+ }
+
+ public void setSecurityLevel(String securityLevel) {
+ this.securityLevel = securityLevel;
+ }
+
+ public Employee(String firstName, String lastName, String securityLevel) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.securityLevel = securityLevel;
+ }
+
+}
Property changes on: trunk/Pojomatic/src/test/java/examples/Employee.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/Pojomatic/src/test/java/examples/GetterAccess.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/GetterAccess.java (rev 0)
+++ trunk/Pojomatic/src/test/java/examples/GetterAccess.java 2008-12-02 18:09:19 UTC (rev 74)
@@ -0,0 +1,9 @@
+package examples;
+
+import org.pojomatic.annotations.AutoDetectPolicy;
+import org.pojomatic.annotations.AutoProperty;
+
+@AutoProperty(autoDetect=AutoDetectPolicy.METHOD)
+public class GetterAccess {
+
+}
Property changes on: trunk/Pojomatic/src/test/java/examples/GetterAccess.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/Pojomatic/src/test/java/examples/Manual.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/Manual.java (rev 0)
+++ trunk/Pojomatic/src/test/java/examples/Manual.java 2008-12-02 18:09:19 UTC (rev 74)
@@ -0,0 +1,37 @@
+package examples;
+
+import org.pojomatic.Pojomatic;
+import org.pojomatic.Pojomator;
+import org.pojomatic.annotations.AutoProperty;
+
+@AutoProperty //all fields are included by default
+public class Manual {
+ private String firstName, lastName;
+
+ public Manual(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+
+ public String getFirstName() { return this.firstName; }
+ public String getLastName() { return this.lastName; }
+
+ private final static Pojomator<Manual> POJOMATOR = Pojomatic.pojomator(Manual.class);
+
+ @Override public boolean equals(Object other) {
+ return POJOMATOR.doEquals(this, other);
+ }
+
+ @Override public int hashCode() {
+ return POJOMATOR.doHashCode(this);
+ }
+
+ @Override public String toString() {
+ return POJOMATOR.doToString(this);
+ }
+
+ public static void main(String[] args) {
+ System.out.println(new Manual("first", "last"));
+ }
+}
Property changes on: trunk/Pojomatic/src/test/java/examples/Manual.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-02 18:08:49
|
Revision: 73
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=73&view=rev
Author: iroberts
Date: 2008-12-02 18:08:46 +0000 (Tue, 02 Dec 2008)
Log Message:
-----------
Add a EQUALS_TO_STRING policy option
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java
trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java 2008-12-01 21:02:19 UTC (rev 72)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java 2008-12-02 18:08:46 UTC (rev 73)
@@ -34,6 +34,14 @@
EQUALS(PropertyRole.EQUALS),
/**
+ * Use all properties for both {@code equals} and {@code toString} by default.
+ *
+ * @see Object#equals(Object)
+ * @see Object#toString()
+ */
+ EQUALS_TO_STRING(PropertyRole.EQUALS, PropertyRole.TO_STRING),
+
+ /**
* Use all properties for both {@code toString} only by default.
*
* @see Object#toString()
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java 2008-12-01 21:02:19 UTC (rev 72)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java 2008-12-02 18:08:46 UTC (rev 73)
@@ -27,6 +27,15 @@
HASHCODE_EQUALS(PropertyRole.HASH_CODE, PropertyRole.EQUALS),
/**
+ * Use the property for both {@code equals} and {@code toString}.
+ *
+ * @see Object#equals(Object)
+ * @see Object#toString()
+ */
+ EQUALS_TO_STRING(PropertyRole.EQUALS, PropertyRole.TO_STRING),
+
+
+ /**
* Use the property for {@code equals} only.
*
* @see Object#equals(Object)
Modified: trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java
===================================================================
--- trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java 2008-12-01 21:02:19 UTC (rev 72)
+++ trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java 2008-12-02 18:08:46 UTC (rev 73)
@@ -18,20 +18,24 @@
public class ClassPropertiesTest {
-
@Test
public void testAnnotatedFields() throws Exception {
final PropertyElement privateStringField = TestUtils.field(FieldPojo.class, "privateString");
final PropertyElement publicIntField = TestUtils.field(FieldPojo.class, "publicInt");
final PropertyElement onlyForStringField = TestUtils.field(FieldPojo.class, "onlyForToString");
+ final PropertyElement forEqualsAndToString =
+ TestUtils.field(FieldPojo.class, "forEqualsAndToString");
ClassProperties classProperties = ClassProperties.createInstance(FieldPojo.class);
- Set<PropertyElement> expected = asSet(privateStringField, publicIntField);
- assertEquals(expected, asSet(classProperties.getEqualsProperties()));
- assertEquals(expected, asSet(classProperties.getHashCodeProperties()));
assertEquals(
- asSet(privateStringField, publicIntField, onlyForStringField),
+ asSet(privateStringField, publicIntField, forEqualsAndToString),
+ asSet(classProperties.getEqualsProperties()));
+ assertEquals(
+ asSet(privateStringField, publicIntField),
+ asSet(classProperties.getHashCodeProperties()));
+ assertEquals(
+ asSet(privateStringField, publicIntField, onlyForStringField, forEqualsAndToString),
asSet(classProperties.getToStringProperties()));
}
@@ -177,6 +181,10 @@
@SuppressWarnings("unused")
@Property(policy=PojomaticPolicy.TO_STRING)
private int onlyForToString;
+
+ @SuppressWarnings("unused")
+ @Property(policy=PojomaticPolicy.EQUALS_TO_STRING)
+ private int forEqualsAndToString;
}
@AutoProperty(policy=DefaultPojomaticPolicy.TO_STRING)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-12-01 21:02:25
|
Revision: 72
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=72&view=rev
Author: iroberts
Date: 2008-12-01 21:02:19 +0000 (Mon, 01 Dec 2008)
Log Message:
-----------
a start at overview; needs more work...
Added Paths:
-----------
trunk/Pojomatic/src/main/javadoc/
trunk/Pojomatic/src/main/javadoc/overview.html
Added: trunk/Pojomatic/src/main/javadoc/overview.html
===================================================================
--- trunk/Pojomatic/src/main/javadoc/overview.html (rev 0)
+++ trunk/Pojomatic/src/main/javadoc/overview.html 2008-12-01 21:02:19 UTC (rev 72)
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC
+ "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <title>Overview</title>
+</head>
+<body>
+Pojomatic is a library which allows simple creation of the three methods
+{@link Object#equals(Object)}, {@link Object#hashCode()} and {@link Object#toString()} by
+annotating properties. There are two steps to pojomatize a pojo class: annotating, and implementing
+the three methods.
+
+<h2>Annotations</h2>
+Pojomatic behavior is controlled by annotations; these can be on a property-by-property basis, a
+class-wide basis, or a mix of the two. Class wide behavior can be controlled by the
+{@link org.pojomatic.annotations.AutoProperty AutoProperty} and
+{@link org.pojomatic.annotations.PojoFormat PojoFormat}, while property-specific behavior can be
+controlled by the {@link org.pojomatic.annotations.Property Property} and
+{@link org.pojomatic.annotations.PojoFormat PropertyFormat} annotations. A recommended practice is
+to provide an {@code AutoProperty} annotation at the class level, and the override the behavior it
+specifies on a per-property basis as needed. This minimizes both the number of annotations needed,
+as well as the number of additional steps needed when adding new properties to a class.
+</body>
+</html>
Property changes on: trunk/Pojomatic/src/main/javadoc/overview.html
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-11-10 22:22:36
|
Revision: 70
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=70&view=rev
Author: iroberts
Date: 2008-11-10 21:34:24 +0000 (Mon, 10 Nov 2008)
Log Message:
-----------
*) Rename AutoDetectType to AutoDetectPolicy
*) Improve javadoc
Modified Paths:
--------------
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoProperty.java
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java
trunk/Pojomatic/src/main/java/org/pojomatic/formatter/AccountNumberFormatter.java
trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPropertyFormatter.java
trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java
trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java
Added Paths:
-----------
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectPolicy.java
Removed Paths:
-------------
trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectType.java
Copied: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectPolicy.java (from rev 69, trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectType.java)
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectPolicy.java (rev 0)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectPolicy.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -0,0 +1,25 @@
+package org.pojomatic.annotations;
+
+/**
+ * A policy for determining which class members are automatically detected as properties. This
+ * policy is set class-wide using {@link AutoProperty}.
+ */
+public enum AutoDetectPolicy {
+ /**
+ * Auto-detect fields of the class as properties
+ */
+ FIELD,
+
+ /**
+ * Auto-detect accessor methods of the class as properties using the JavaBean conventions
+ * (i.e. getX and isX).
+ */
+ METHOD,
+
+ /**
+ * Do not auto-detect properties for the class. This is be useful to specify
+ * a different {@link PojomaticPolicy} in {@link AutoProperty} without enabling
+ * property auto-detection.
+ */
+ NONE;
+}
Property changes on: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectPolicy.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectType.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectType.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoDetectType.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -1,20 +0,0 @@
-package org.pojomatic.annotations;
-
-public enum AutoDetectType {
- /**
- * Auto-detect fields of the class as properties
- */
- FIELD,
-
- /**
- * Auto-detect methods of the class as properties using the JavaBean conventions (i.e. getX).
- */
- METHOD,
-
- /**
- * Do not auto-detect properties for the class. This is be useful to specify
- * a different {@link PojomaticPolicy} in {@link AutoProperty} without enabling
- * property auto-detection.
- */
- NONE;
-}
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoProperty.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoProperty.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/AutoProperty.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -26,5 +26,5 @@
/**
* Specifies whether to auto-detect properties by their fields, getters or not at all.
*/
- public AutoDetectType autoDetect() default AutoDetectType.FIELD;
+ public AutoDetectPolicy autoDetect() default AutoDetectPolicy.FIELD;
}
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/DefaultPojomaticPolicy.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -8,13 +8,15 @@
import org.pojomatic.internal.PropertyRole;
/**
- * Defines which sets of {@link Pojomatic} operations that properties should be included.
- * This are set class-wide using {@link AutoProperty} and for
- * an individual property using {@link Property}.
+ * A policy for defining which sets of {@link Pojomatic} operations
+ * ({@code equals}, {@code hashCode} and {@code toString}) should use all properties by default.
+ * This is set class-wide using {@link AutoProperty}.
+ * @see PojomaticPolicy
*/
public enum DefaultPojomaticPolicy {
/**
+ * Use all properties for both {@code hashCode} and {@code equals} by default.
* Anything included in {@code public int hashCode()} should also be included in
* {@code public boolean equals(Object)} to preserve the general
* contract of {@link Object#hashCode()}.
@@ -25,26 +27,27 @@
HASHCODE_EQUALS(PropertyRole.HASH_CODE, PropertyRole.EQUALS),
/**
- * {@code public boolean equals(Object)}
+ * Use all properties for {@code equals} only by default.
*
* @see Object#equals(Object)
*/
EQUALS(PropertyRole.EQUALS),
/**
- * {@code public String toString()}
+ * Use all properties for both {@code toString} only by default.
*
* @see Object#toString()
*/
TO_STRING(PropertyRole.TO_STRING),
/**
- * Shorthand for all of the above.
+ * Use all properties for {@code hashCode}, {@code equals} and {@code toString} by default.
*/
ALL(PropertyRole.EQUALS, PropertyRole.HASH_CODE, PropertyRole.TO_STRING),
/**
- * Shorthand for none of the above.
+ * Do not use any properties for any of {@code hashCode}, {@code equals} or {@code toString}
+ * by default.
*/
NONE();
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/annotations/PojomaticPolicy.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -8,13 +8,15 @@
import org.pojomatic.internal.PropertyRole;
/**
- * Defines which sets of {@link Pojomatic} operations that properties should be included.
- * This are set class-wide using {@link AutoProperty} and for
- * an individual property using {@link Property}.
+ * A policy for defining which sets of {@link Pojomatic} operations
+ * ({@code equals}, {@code hashCode} and {@code toString}) should a property.
+ * This is set using {@link Property}.
+ * @see DefaultPojomaticPolicy
*/
public enum PojomaticPolicy {
/**
+ * Use the property for both {@code hashCode} and {@code equals}.
* Anything included in {@code public int hashCode()} should also be included in
* {@code public boolean equals(Object)} to preserve the general
* contract of {@link Object#hashCode()}.
@@ -25,26 +27,26 @@
HASHCODE_EQUALS(PropertyRole.HASH_CODE, PropertyRole.EQUALS),
/**
- * {@code public boolean equals(Object)}
+ * Use the property for {@code equals} only.
*
* @see Object#equals(Object)
*/
EQUALS(PropertyRole.EQUALS),
/**
- * {@code public String toString()}
+ * Use the property for both {@code toString} only.
*
* @see Object#toString()
*/
TO_STRING(PropertyRole.TO_STRING),
/**
- * Shorthand for all of the above.
+ * Use the property for {@code hashCode}, {@code equals} and {@code toString}.
*/
ALL(PropertyRole.EQUALS, PropertyRole.HASH_CODE, PropertyRole.TO_STRING),
/**
- * Shorthand for none of the above.
+ * Do not use the property for any of {@code hashCode}, {@code equals} or {@code toString}.
*/
NONE(),
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/formatter/AccountNumberFormatter.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/formatter/AccountNumberFormatter.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/formatter/AccountNumberFormatter.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -6,9 +6,10 @@
import org.pojomatic.annotations.Property;
/**
- * Shows only the last 4 characters of a {@link Property}. Useful for credit card numbers, social
- * security numbers, etc. This formatter cannot be used with properties of array types.
- * <br><br>
+ * A property formatter which shows only the last 4 characters of the string representation of the
+ * {@link Property}, with all others replaced by an asterisk ('*').
+ * Useful for credit card numbers, social security numbers, etc.
+ * <p>
* For example, a 16 character {@code String} representing a credit card number would
* be formatted as "************1234".
*/
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPropertyFormatter.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPropertyFormatter.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/formatter/DefaultPropertyFormatter.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -3,6 +3,12 @@
import java.lang.reflect.AnnotatedElement;
import java.util.Arrays;
+/**
+ * The default property formatter used by Pojomatic. While the particulars of the formatting
+ * strategy are subject to change, the general principle is to provide a meaningful representation.
+ * In particular, arrays are formatted "deeply", rather than simply showing the default toString
+ * representation of Java arrays.
+ */
public class DefaultPropertyFormatter implements PropertyFormatter {
public void initialize(AnnotatedElement element) {
//Not applicable
Modified: trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java
===================================================================
--- trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -9,7 +9,7 @@
import java.util.regex.Pattern;
import org.pojomatic.PropertyElement;
-import org.pojomatic.annotations.AutoDetectType;
+import org.pojomatic.annotations.AutoDetectPolicy;
import org.pojomatic.annotations.AutoProperty;
import org.pojomatic.annotations.DefaultPojomaticPolicy;
import org.pojomatic.annotations.PojomaticPolicy;
@@ -42,7 +42,7 @@
/* add all fields that are explicitly annotated or auto-detected */
if (propertyPolicy != null ||
- (autoProperty != null && AutoDetectType.FIELD == autoProperty.autoDetect())) {
+ (autoProperty != null && AutoDetectPolicy.FIELD == autoProperty.autoDetect())) {
for (PropertyRole role : PropertyFilter.getRoles(propertyPolicy, classPolicy)) {
properties.get(role).add(new PropertyField(field));
}
@@ -66,7 +66,7 @@
/* add all methods that are explicitly annotated or auto-detected */
if (propertyPolicy != null ||
- (autoProperty != null && AutoDetectType.METHOD == autoProperty.autoDetect())) {
+ (autoProperty != null && AutoDetectPolicy.METHOD == autoProperty.autoDetect())) {
for (PropertyRole role : PropertyFilter.getRoles(propertyPolicy, classPolicy)) {
properties.get(role).add(new PropertyAccessor(method));
}
Modified: trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java
===================================================================
--- trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java 2008-10-20 21:53:40 UTC (rev 69)
+++ trunk/Pojomatic/src/test/java/org/pojomatic/internal/ClassPropertiesTest.java 2008-11-10 21:34:24 UTC (rev 70)
@@ -10,7 +10,7 @@
import org.junit.Test;
import org.pojomatic.PropertyElement;
import org.pojomatic.TestUtils;
-import org.pojomatic.annotations.AutoDetectType;
+import org.pojomatic.annotations.AutoDetectPolicy;
import org.pojomatic.annotations.AutoProperty;
import org.pojomatic.annotations.DefaultPojomaticPolicy;
import org.pojomatic.annotations.PojomaticPolicy;
@@ -205,7 +205,7 @@
public double onlyForEquals() { return 0.0; }
}
- @AutoProperty(autoDetect=AutoDetectType.METHOD, policy=DefaultPojomaticPolicy.ALL)
+ @AutoProperty(autoDetect=AutoDetectPolicy.METHOD, policy=DefaultPojomaticPolicy.ALL)
public static class AutoMethodPojo {
/* Fields are not auto-detected */
int notDetected;
@@ -254,7 +254,7 @@
@Override public int getFoo() { return 2; }
}
- @AutoProperty(autoDetect=AutoDetectType.METHOD)
+ @AutoProperty(autoDetect=AutoDetectPolicy.METHOD)
private static class ChildExtendsAnnotatedPojo extends ParentPojo {
@Override
public int getFoo() { return 0; }
@@ -262,12 +262,12 @@
public String getMyString() { return "foo"; }
}
- @AutoProperty(autoDetect=AutoDetectType.METHOD, policy=DefaultPojomaticPolicy.EQUALS)
+ @AutoProperty(autoDetect=AutoDetectPolicy.METHOD, policy=DefaultPojomaticPolicy.EQUALS)
private static abstract class ParentAutoPojo {
public abstract int getFoo();
}
- @AutoProperty(autoDetect=AutoDetectType.FIELD, policy=DefaultPojomaticPolicy.TO_STRING)
+ @AutoProperty(autoDetect=AutoDetectPolicy.FIELD, policy=DefaultPojomaticPolicy.TO_STRING)
private static class ChildAutoPojo extends ParentAutoPojo {
public String other;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-11-10 22:02:33
|
Revision: 71
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=71&view=rev
Author: iroberts
Date: 2008-11-10 22:02:30 +0000 (Mon, 10 Nov 2008)
Log Message:
-----------
Maven documentation
Added Paths:
-----------
trunk/Pojomatic/src/site/
trunk/Pojomatic/src/site/apt/
trunk/Pojomatic/src/site/apt/index.apt
trunk/Pojomatic/src/test/java/examples/Person.java
trunk/Pojomatic/src/test/java/examples/PersonMain.java
Added: trunk/Pojomatic/src/site/apt/index.apt
===================================================================
--- trunk/Pojomatic/src/site/apt/index.apt (rev 0)
+++ trunk/Pojomatic/src/site/apt/index.apt 2008-11-10 22:02:30 UTC (rev 71)
@@ -0,0 +1,58 @@
+ ------
+ Pojomatic
+ ------
+ ------
+ ------
+
+
+ Pojomatic provides configurable implementations of the <<<equals(Object)>>>, <<<toString()>>>
+ and <<<hashCode()>>> methods inherited from <<<java.lang.Object>>>.
+
+ For example, the following bean has been "pojomated":
+
+------------------------
+import org.pojomatic.Pojomatic;
+import org.pojomatic.annotations.AutoProperty;
+
+@AutoProperty
+public class Person {
+ private final String firstName;
+ private final String lastName;
+ private final int age;
+
+ public Person(String firstName, String lastName, int age) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public String getFirstName() { return this.firstName; }
+ public String getLastName() { return this.lastName; }
+ public int getAge() { return this.age; }
+
+ @Override public boolean equals(Object o) {
+ return Pojomatic.equals(this, o);
+ }
+
+ @Override public int hashCode() {
+ return Pojomatic.hashCode(this);
+ }
+
+ @Override public String toString() {
+ return Pojomatic.toString(this);
+ }
+}
+------------------------
+
+ The above class implements <<<equals>>> and <<<hashCode>>> methods following the best practices
+ outlined in Josh Bloch's <Efective Java>. Moreover, running
+
+---
+ System.out.println(new Person("John", "Doe", 32).toString());
+---
+
+ will result in the following output:
+
+--------
+Person{firstName: {John}, lastName: {Doe}, age: {32}}
+--------
Added: trunk/Pojomatic/src/test/java/examples/Person.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/Person.java (rev 0)
+++ trunk/Pojomatic/src/test/java/examples/Person.java 2008-11-10 22:02:30 UTC (rev 71)
@@ -0,0 +1,41 @@
+package examples;
+
+import org.pojomatic.Pojomatic;
+import org.pojomatic.annotations.AutoProperty;
+
+@AutoProperty
+public class Person {
+ private final String firstName;
+ private final String lastName;
+ private final int age;
+
+ public Person(String firstName, String lastName, int age) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public int getAge() {
+ return this.age;
+ }
+
+ @Override public int hashCode() {
+ return Pojomatic.hashCode(this);
+ }
+
+ @Override public String toString() {
+ return Pojomatic.toString(this);
+ }
+
+ @Override public boolean equals(Object o) {
+ return Pojomatic.equals(this, o);
+ }
+}
Property changes on: trunk/Pojomatic/src/test/java/examples/Person.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/Pojomatic/src/test/java/examples/PersonMain.java
===================================================================
--- trunk/Pojomatic/src/test/java/examples/PersonMain.java (rev 0)
+++ trunk/Pojomatic/src/test/java/examples/PersonMain.java 2008-11-10 22:02:30 UTC (rev 71)
@@ -0,0 +1,7 @@
+package examples;
+
+public class PersonMain {
+ public static void main(String[] args) {
+ System.out.println(new Person("John", "Doe", 32).toString());
+ }
+}
Property changes on: trunk/Pojomatic/src/test/java/examples/PersonMain.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-10-20 21:53:49
|
Revision: 69
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=69&view=rev
Author: iroberts
Date: 2008-10-20 21:53:40 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
[maven-release-plugin] prepare for next development iteration
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-10-20 21:53:36 UTC (rev 68)
+++ trunk/Pojomatic/pom.xml 2008-10-20 21:53:40 UTC (rev 69)
@@ -3,7 +3,7 @@
<groupId>org.pojomatic</groupId>
<artifactId>pojomatic</artifactId>
<packaging>jar</packaging>
- <version>0.1</version>
+ <version>0.2-SNAPSHOT</version>
<name>Pojomatic</name>
<description>
Automatically provides configurable implementations of the
@@ -12,9 +12,9 @@
<url>http://www.pojomatic.org</url>
<inceptionYear>2008</inceptionYear>
<scm>
- <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</connection>
- <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</developerConnection>
- <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</url>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</url>
</scm>
<developers>
<developer>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-10-20 21:53:45
|
Revision: 68
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=68&view=rev
Author: iroberts
Date: 2008-10-20 21:53:36 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
[maven-release-plugin] copy for tag pojomatic-0.1
Added Paths:
-----------
tags/pojomatic-0.1/
tags/pojomatic-0.1/pom.xml
Removed Paths:
-------------
tags/pojomatic-0.1/pom.xml
Deleted: tags/pojomatic-0.1/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-09-08 21:39:26 UTC (rev 56)
+++ tags/pojomatic-0.1/pom.xml 2008-10-20 21:53:36 UTC (rev 68)
@@ -1,145 +0,0 @@
-<project
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.pojomatic</groupId>
- <artifactId>pojomatic</artifactId>
- <packaging>jar</packaging>
- <version>0.1-SNAPSHOT</version>
- <name>Pojomatic</name>
- <description>
- Automatically provides configurable implementations of the
- equals(Object), toString() and hashCode() methods inherited from java.lang.Object
- </description>
- <url>http://www.pojomatic.org</url>
- <inceptionYear>2008</inceptionYear>
- <scm>
- <connection>scm:svn:https://pojomatic.googlecode.com/svn/trunk/pojomatic</connection>
- <developerConnection>scm:svn:https://pojomatic.googlecode.com/svn/trunk/pojomatic</developerConnection>
- <url>https://pojomatic.googlecode.com/svn/trunk/pojomatic</url>
- </scm>
- <developers>
- <developer>
- <name>Ian Robertson</name>
- <roles>
- <role>Lead Developer</role>
- </roles>
- <email>ian...@gm...</email>
- <id>ian.b.robertson</id>
- <organization>Overstock.com</organization>
- <organizationUrl>http://www.overstock.com</organizationUrl>
- <url>http://www.artima.com/weblogs/index.jsp?blogger=ianr</url>
- </developer>
- <developer>
- <name>Chris Hansen</name>
- <roles>
- <role>Lead Developer</role>
- </roles>
- <email>han...@gm...</email>
- <id>hansen.chris.w</id>
- <organization>Overstock.com</organization>
- <organizationUrl>http://www.overstock.com</organizationUrl>
- <url>http://polyglot-window.blogspot.com/</url>
- </developer>
- </developers>
- <licenses>
- <license>
- <name>Apache License 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <issueManagement>
- <system>Google Code</system>
- <url>http://code.google.com/p/pojomatic/issues/list</url>
- </issueManagement>
- <distributionManagement>
- <downloadUrl>http://code.google.com/p/pojomatic/downloads/list</downloadUrl>
- </distributionManagement>
- <mailingLists>
- <mailingList>
- <name>pojomatic-user</name>
- <subscribe>poj...@go...</subscribe>
- <unsubscribe>poj...@go...</unsubscribe>
- <post>poj...@go...</post>
- <archive>http://groups.google.com/group/pojomatic-user</archive>
- </mailingList>
- </mailingLists>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
- <configuration>
- <excludes>
- <exclude>**/TestUtils.java</exclude>
- <exclude>examples/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.4</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-5</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>1.1.1</version>
- <configuration>
- <excludeFilterFile>${basedir}/FindBugsFilter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.4.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- <rulesets>
- <ruleset>${project.basedir}/src/pmd.xml</ruleset>
- </rulesets>
- <includeTests>true</includeTests>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- </plugins>
- </reporting>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
Copied: tags/pojomatic-0.1/pom.xml (from rev 67, trunk/Pojomatic/pom.xml)
===================================================================
--- tags/pojomatic-0.1/pom.xml (rev 0)
+++ tags/pojomatic-0.1/pom.xml 2008-10-20 21:53:36 UTC (rev 68)
@@ -0,0 +1,157 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.pojomatic</groupId>
+ <artifactId>pojomatic</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1</version>
+ <name>Pojomatic</name>
+ <description>
+ Automatically provides configurable implementations of the
+ equals(Object), toString() and hashCode() methods inherited from java.lang.Object
+ </description>
+ <url>http://www.pojomatic.org</url>
+ <inceptionYear>2008</inceptionYear>
+ <scm>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</url>
+ </scm>
+ <developers>
+ <developer>
+ <name>Ian Robertson</name>
+ <roles>
+ <role>Lead Developer</role>
+ </roles>
+ <email>ian...@gm...</email>
+ <id>ian.b.robertson</id>
+ <organization>Overstock.com</organization>
+ <organizationUrl>http://www.overstock.com</organizationUrl>
+ <url>http://www.artima.com/weblogs/index.jsp?blogger=ianr</url>
+ </developer>
+ <developer>
+ <name>Chris Hansen</name>
+ <roles>
+ <role>Lead Developer</role>
+ </roles>
+ <email>han...@gm...</email>
+ <id>hansen.chris.w</id>
+ <organization>Overstock.com</organization>
+ <organizationUrl>http://www.overstock.com</organizationUrl>
+ <url>http://polyglot-window.blogspot.com/</url>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>Apache License 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <issueManagement>
+ <system>Sourceforge</system>
+ <url>https://sourceforge.net/tracker/?func=browse&group_id=239113</url>
+ </issueManagement>
+ <distributionManagement>
+ <repository>
+ <id>pojomatic-releases</id>
+ <name>Pojomatic Release Repository</name>
+ <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/releases</url>
+ </repository>
+ <snapshotRepository>
+ <id>pojomatic-snapshots</id>
+ <name>Pojomatic snapshot Repository</name>
+ <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/snapshots</url>
+ </snapshotRepository>
+ <site>
+ <id>pojomatic-site</id>
+ <name>Pojomatic</name>
+ <url>sftp://web.sourceforge.net/home/groups/p/po/pojomatic/htdocs/site</url>
+ </site>
+ </distributionManagement>
+ <mailingLists>
+ <mailingList>
+ <archive>http://sourceforge.net/mailarchive/forum.php?forum_name=pojomatic-users</archive>
+ <name>pojomatic-users</name>
+ <post>poj...@li...</post>
+ <subscribe>http://lists.sourceforge.net/mailman/listinfo/pojomatic-users</subscribe>
+ <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/pojomatic-users</unsubscribe>
+ </mailingList>
+ </mailingLists>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
+ <configuration>
+ <excludes>
+ <exclude>**/TestUtils.java</exclude>
+ <exclude>examples/*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.0-beta-5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <configuration>
+ <excludeFilterFile>${basedir}/FindBugsFilter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.4.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <targetJdk>1.5</targetJdk>
+ <rulesets>
+ <ruleset>${project.basedir}/src/pmd.xml</ruleset>
+ </rulesets>
+ <includeTests>true</includeTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-10-20 21:53:40
|
Revision: 67
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=67&view=rev
Author: iroberts
Date: 2008-10-20 21:53:28 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
[maven-release-plugin] prepare release pojomatic-0.1
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-10-20 21:53:08 UTC (rev 66)
+++ trunk/Pojomatic/pom.xml 2008-10-20 21:53:28 UTC (rev 67)
@@ -1,11 +1,9 @@
-<project
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.pojomatic</groupId>
<artifactId>pojomatic</artifactId>
<packaging>jar</packaging>
- <version>0.1-SNAPSHOT</version>
+ <version>0.1</version>
<name>Pojomatic</name>
<description>
Automatically provides configurable implementations of the
@@ -14,9 +12,9 @@
<url>http://www.pojomatic.org</url>
<inceptionYear>2008</inceptionYear>
<scm>
- <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</connection>
- <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</developerConnection>
- <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</url>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</url>
</scm>
<developers>
<developer>
@@ -156,4 +154,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-10-20 21:53:17
|
Revision: 66
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=66&view=rev
Author: iroberts
Date: 2008-10-20 21:53:08 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
botched release
Removed Paths:
-------------
tags/pojomatic-0.1/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <iro...@us...> - 2008-10-20 21:52:40
|
Revision: 65
http://pojomatic.svn.sourceforge.net/pojomatic/?rev=65&view=rev
Author: iroberts
Date: 2008-10-20 21:52:36 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
[maven-release-plugin] rollback the release of pojomatic-0.1
Modified Paths:
--------------
trunk/Pojomatic/pom.xml
Modified: trunk/Pojomatic/pom.xml
===================================================================
--- trunk/Pojomatic/pom.xml 2008-10-20 21:52:21 UTC (rev 64)
+++ trunk/Pojomatic/pom.xml 2008-10-20 21:52:36 UTC (rev 65)
@@ -1,9 +1,11 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.pojomatic</groupId>
<artifactId>pojomatic</artifactId>
<packaging>jar</packaging>
- <version>0.1</version>
+ <version>0.1-SNAPSHOT</version>
<name>Pojomatic</name>
<description>
Automatically provides configurable implementations of the
@@ -12,9 +14,9 @@
<url>http://www.pojomatic.org</url>
<inceptionYear>2008</inceptionYear>
<scm>
- <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</connection>
- <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</developerConnection>
- <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic/tags/pojomatic-0.1</url>
+ <connection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</connection>
+ <developerConnection>scm:svn:https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</developerConnection>
+ <url>https://pojomatic.svn.sourceforge.net/svnroot/pojomatic</url>
</scm>
<developers>
<developer>
@@ -154,4 +156,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|