Skip to content

Commit

Permalink
Add Eclipse Collections as a dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
itohro committed Jan 24, 2017
1 parent 1c1981b commit 2d27368
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 11 deletions.
8 changes: 8 additions & 0 deletions build/build.xml
Expand Up @@ -21,8 +21,10 @@
<!--todo: remove-->
<property name="mithra.home" value="${env.RELADOMO_HOME}/reladomo"/>
<property name="mithra.generateGscListMethod" value="true"/>
<property name="mithra.generateEcListMethod" value="true"/>

<property name="gs-collections.version" value="5.0.0"/>
<property name="eclipse-collections.version" value="7.1.0"/>
<property name="junit.version" value="4.11"/>
<property name="slf4j.version" value="1.6.4"/>
<property name="jtdsjbcp.version" value="1.2.0.15"/>
Expand Down Expand Up @@ -665,12 +667,14 @@
<reladomo-gen xml="${root}/reladomo/src/test/reladomo-xml/MithraClassListToImport.xml"
generatedDir="${root}/reladomo/target/test-generated-onheap-src"
nonGeneratedDir="${root}/reladomo/src/test/java"
generateEcListMethod="${mithra.generateEcListMethod}"
generateGscListMethod="${mithra.generateGscListMethod}"
generateConcreteClasses="${reladomo.generateConcreteClasses}">
</reladomo-gen>
<reladomo-gen xml="${root}/reladomo/src/test/reladomo-xml/MithraClassList.xml"
generatedDir="${root}/reladomo/target/test-generated-onheap-src"
nonGeneratedDir="${root}/reladomo/src/test/java"
generateEcListMethod="${mithra.generateEcListMethod}"
generateGscListMethod="${mithra.generateGscListMethod}"
generateConcreteClasses="${reladomo.generateConcreteClasses}">
<mithraImport dir="${root}/reladomo/src/test/reladomo-xml/" fileName="MithraClassListToImport.xml"/>
Expand All @@ -687,13 +691,15 @@
forceOffHeap="true"
generatedDir="${root}/reladomo/target/test-generated-offheap-src"
nonGeneratedDir="${root}/reladomo/src/test/java"
generateEcListMethod="${mithra.generateEcListMethod}"
generateGscListMethod="${mithra.generateGscListMethod}"
generateConcreteClasses="${reladomo.generateConcreteClasses}">
</reladomo-gen>
<reladomo-gen xml="${root}/reladomo/src/test/reladomo-xml/MithraClassList.xml"
forceOffHeap="true"
generatedDir="${root}/reladomo/target/test-generated-offheap-src"
nonGeneratedDir="${root}/reladomo/src/test/java"
generateEcListMethod="${mithra.generateEcListMethod}"
generateGscListMethod="${mithra.generateGscListMethod}"
generateConcreteClasses="${reladomo.generateConcreteClasses}">
<mithraImport dir="${root}/reladomo/src/test/reladomo-xml/" fileName="MithraClassListToImport.xml"/>
Expand Down Expand Up @@ -728,6 +734,7 @@
<reladomo-gen xml="${root}/reladomo/src/test/reladomo-xml/finalgetter/MithraFinalGetterClassList.xml"
generatedDir="${root}/reladomo/target/test-generated-onheap-src"
nonGeneratedDir="${root}/reladomo/src/test/java"
generateEcListMethod="${mithra.generateEcListMethod}"
generateGscListMethod="${mithra.generateGscListMethod}"
generateConcreteClasses="${reladomo.generateConcreteClasses}"
defaultFinalGetters="true">
Expand All @@ -736,6 +743,7 @@
forceOffHeap="true"
generatedDir="${root}/reladomo/target/test-generated-offheap-src"
nonGeneratedDir="${root}/reladomo/src/test/java"
generateEcListMethod="${mithra.generateEcListMethod}"
generateGscListMethod="${mithra.generateGscListMethod}"
generateConcreteClasses="${reladomo.generateConcreteClasses}"
defaultFinalGetters="true">
Expand Down
14 changes: 14 additions & 0 deletions build/pom-templates/pom-mithragenxml.xml
Expand Up @@ -53,6 +53,20 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
<version>@eclipse-collections.version@</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>@eclipse-collections.version@</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.gs.fw.aig.jdbc</groupId>
<artifactId>jndijdbc</artifactId>
Expand Down
14 changes: 14 additions & 0 deletions build/pom-templates/pom-mithratestresource.xml
Expand Up @@ -47,6 +47,20 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
<version>@eclipse-collections.version@</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>@eclipse-collections.version@</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
12 changes: 12 additions & 0 deletions build/pom-templates/pom-reladomo.xml
Expand Up @@ -64,6 +64,18 @@
<version>5.1.0</version>
</dependency>

<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
<version>7.1.0</version>
</dependency>

<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>7.1.0</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions build/reladomolib.spec
Expand Up @@ -2,6 +2,8 @@
# central,org.apache.ant,ant,1.9.6,jar,build/lib,80E2063B01BAB3C79C2D84E4ED5E73868394C85A
central,com.goldmansachs,gs-collections-api,5.1.0,jar,lib/compile,EA605CDF64CAB5FC7B48C99F061D4C8DB05B6FF1
central,com.goldmansachs,gs-collections,5.1.0,jar,lib/compile,07114C5349C816EA645B1EA3FFCC21FA073CBABC
central,org.eclipse.collections,eclipse-collections-api,7.1.0,jar,lib/compile,DB56A4C791FBC1898EF62BC0B0090C1AB42A8552
central,org.eclipse.collections,eclipse-collections,7.1.0,jar,lib/compile,2376A19880033964254D6D57C82C1C5587D4C2FB
central,joda-time,joda-time,2.9.4,jar,lib/compile,1C295B462F16702EBE720BBB08F62E1BA80DA41B
central,org.apache.geronimo.specs,geronimo-jta_1.1_spec,1.1.1,jar,lib/compile,AABAB3165B8EA936B9360ABBF448459C0D04A5A4
central,org.slf4j,slf4j-api,1.7.21,jar,lib/compile,139535A69A4239DB087DE9BAB0BEE568BF8E0B70
Expand Down
Expand Up @@ -18,11 +18,8 @@

import com.gs.collections.api.block.function.Function;



public class ChainedAttributeValueSelector implements Function
public class ChainedAttributeValueSelector implements Function, org.eclipse.collections.api.block.function.Function
{

private Function first;
private Function second;

Expand Down
Expand Up @@ -18,8 +18,7 @@

import com.gs.collections.api.block.function.Function;


public interface HashableValueSelector<T, V> extends Function<T, V>
public interface HashableValueSelector<T, V> extends Function<T, V>, org.eclipse.collections.api.block.function.Function<T, V>
{
public int valueHashCode(T object);

Expand Down
Expand Up @@ -19,10 +19,7 @@
import com.gs.collections.api.block.function.Function;
import com.gs.fw.common.mithra.attribute.calculator.procedure.ObjectProcedure;



public interface NormalAndListValueSelector<T, V> extends ListValueSelector, Function<T, V>
public interface NormalAndListValueSelector<T, V> extends ListValueSelector, Function<T, V>, org.eclipse.collections.api.block.function.Function<T, V>
{

public void forEach(ObjectProcedure proc, T obj, Object context);
}
Expand Up @@ -1415,6 +1415,61 @@ public void value(Order order, int index)
assertEquals(hash, hashArray[0]);
}

public void testEclipseCollectionsList()
{
int start = 0xAE4927BE;
OrderList list = OrderFinder.findMany(OrderFinder.all());
int hash = 0xAE4927BE;
for(int i = 0;i<list.size();i++)
{
hash = HashUtil.combineHashes(hash, list.get(i).getOrderId());
}
checkForEach(start, OrderFinder.findMany(OrderFinder.all()).asEcList(), hash);
checkForEach(start, list.asEcList(), hash);
OrderList adhocList = new OrderList(list);
checkForEach(start, adhocList.asEcList(), hash);
checkForEach(start, list.asEcList(), hash);
checkForEach(start, adhocList.asEcList(), hash);

// non MutableList extras:
assertEquals(!adhocList.isEmpty(), adhocList.notEmpty());
assertEquals(!list.isEmpty(), list.notEmpty());
assertEquals(!list.asGscList().isEmpty(), list.asGscList().notEmpty());
assertEquals(!adhocList.asGscList().isEmpty(), adhocList.asGscList().notEmpty());
}

private void checkForEach(int start, org.eclipse.collections.api.list.MutableList list, int hash)
{
final int[] hashArray = new int[1];
hashArray[0] = start;
list.forEach(new org.eclipse.collections.api.block.procedure.Procedure<Order>()
{
public void value(Order order)
{
hashArray[0] = HashUtil.combineHashes(hashArray[0], order.getOrderId());
}
});
assertEquals(hash, hashArray[0]);
hashArray[0] = start;
list.forEachWith(new org.eclipse.collections.api.block.procedure.Procedure2<Order, int[]>()
{
public void value(Order order, int[] argument2)
{
argument2[0] = HashUtil.combineHashes(argument2[0], order.getOrderId());
}
}, hashArray);
assertEquals(hash, hashArray[0]);
hashArray[0] = start;
list.forEachWithIndex(new org.eclipse.collections.api.block.procedure.ObjectIntProcedure<Order>()
{
public void value(Order order, int index)
{
hashArray[0] = HashUtil.combineHashes(hashArray[0], order.getOrderId());
}
});
assertEquals(hash, hashArray[0]);
}

public void testEqualsAndHashCode()
{
OrderList orderList = OrderFinder.findMany(OrderFinder.all());
Expand Down
Expand Up @@ -78,6 +78,7 @@ public class CoreMithraGenerator extends BaseMithraGenerator
private boolean executed = false;
private boolean generateConcreteClasses = true;
private boolean warnAboutConcreteClasses = true;
private boolean generateEcListMethod = false;
private boolean generateGscListMethod = false;
private boolean generateLegacyCaramel = false;
private String format = FORMAT_FAST;
Expand Down Expand Up @@ -147,6 +148,11 @@ public void setWarnAboutConcreteClasses(boolean warnAboutConreteClasses)
this.warnAboutConcreteClasses = warnAboutConreteClasses;
}

public void setGenerateEcListMethod(boolean generateEcListMethod)
{
this.generateEcListMethod = generateEcListMethod;
}

public void setGenerateGscListMethod(boolean generateGscListMethod)
{
this.generateGscListMethod = generateGscListMethod;
Expand Down Expand Up @@ -415,6 +421,7 @@ public void run()
writer = new JspWriter(byteArrayOutputStream);
HttpServletRequest request = new HttpServletRequest();
request.setAttribute("mithraWrapper", wrapper);
request.setAttribute("generateEcListMethod", Boolean.valueOf(generateEcListMethod));
request.setAttribute("generateGscListMethod", Boolean.valueOf(generateGscListMethod));
request.setAttribute("generateLegacyCaramel", Boolean.valueOf(false));
HttpServletResponse response = new HttpServletResponse(writer);
Expand Down
Expand Up @@ -57,6 +57,11 @@ public void setWarnAboutConcreteClasses(boolean warnAboutConreteClasses)
this.coreGenerator.setWarnAboutConcreteClasses(warnAboutConreteClasses);
}

public void setGenerateEcListMethod(boolean generateEcListMethod)
{
this.coreGenerator.setGenerateEcListMethod(generateEcListMethod);
}

public void setGenerateGscListMethod(boolean generateGscListMethod)
{
this.coreGenerator.setGenerateGscListMethod(generateGscListMethod);
Expand Down
16 changes: 15 additions & 1 deletion reladomogen/src/main/templates/transactional/ListAbstract.jsp
Expand Up @@ -29,6 +29,7 @@ under the License.
EmbeddedValue[] embeddedValueObjects = wrapper.getEmbeddedValueObjects();
Attribute[] nullablePrimitiveAttributes = wrapper.getNullablePrimitiveAttributes();
Attribute[] pkAttributes = wrapper.getPrimaryKeyAttributes();
boolean isGenerateEcListMethod = (Boolean) request.getAttribute("generateEcListMethod");
boolean isGenerateGscListMethod = (Boolean) request.getAttribute("generateGscListMethod");
%>
package <%= wrapper.getPackageName() %>;
Expand Down Expand Up @@ -128,6 +129,19 @@ public class <%= className %> extends DelegatingList<<%= wrapper.getClassName()
return this.getNonPersistentCopy();
}

<% if (isGenerateEcListMethod) { %>
/**
* Return a view of this list that implements Eclipse Collections MutableList API.
* Since the returned list will be operation-based, it is effectively read-only,
* so mutating methods will throw a RuntimeException.
* (Implemented by a light-weight adapter, not a copy)
*/
public org.eclipse.collections.api.list.MutableList<<%= wrapper.getClassName() %>> asEcList()
{
return org.eclipse.collections.impl.list.mutable.ListAdapter.adapt(this);
}
<% } %>

<% if (isGenerateGscListMethod) { %>
/**
* Return a view of this list that implements GS Collections MutableList API.
Expand Down Expand Up @@ -224,4 +238,4 @@ public class <%= className %> extends DelegatingList<<%= wrapper.getClassName()

<% } %>

}
}

0 comments on commit 2d27368

Please sign in to comment.