Repository: camel
Updated Branches:
  refs/heads/master 793e562a3 -> 8e75e6482


CAMEL-4917: Bindy CSV field should favor using outPos instead of position as 
name as the other is confusing.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8e75e648
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8e75e648
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8e75e648

Branch: refs/heads/master
Commit: 8e75e6482c6c6104cdbd3af5aaec2eacb6d1997b
Parents: 793e562
Author: Claus Ibsen <davscl...@apache.org>
Authored: Sat Jul 11 17:09:09 2015 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Sat Jul 11 17:09:09 2015 +0200

----------------------------------------------------------------------
 .../camel/dataformat/bindy/BindyCsvFactory.java |  2 +-
 .../dataformat/bindy/annotation/DataField.java  |  8 +++++++
 .../simple/oneclassdifferentposition/Order.java | 22 ++++++++++----------
 3 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8e75e648/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
 
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
index 16a4263..2398f18 100755
--- 
a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
+++ 
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
@@ -432,7 +432,7 @@ public class BindyCsvFactory extends BindyAbstractFactory 
implements BindyFactor
                     // Generate a key using the number of the section
                     // and the position of the field
                     Integer key1 = sections.get(obj.getClass().getName());
-                    Integer key2 = datafield.position();
+                    Integer key2 = datafield.outPos() > 0 ? datafield.outPos() 
: datafield.position();
                     Integer keyGenerated = generateKey(key1, key2);
 
                     if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/8e75e648/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
 
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
index cec86c8..179e0dc 100755
--- 
a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
+++ 
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
@@ -91,10 +91,18 @@ public @interface DataField {
 
     /**
      * Position of the field in the message generated (should start from 1)
+     *
+     * @deprecated use {@link #outPos()}
      */
+    @Deprecated
     int position() default 0;
 
     /**
+     * Position of the field in the message generated (should start from 1)
+     */
+    int outPos() default 0;
+
+    /**
      * Indicates if the field is mandatory
      */
     boolean required() default false;

http://git-wip-us.apache.org/repos/asf/camel/blob/8e75e648/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassdifferentposition/Order.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassdifferentposition/Order.java
 
b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassdifferentposition/Order.java
index d160117..0c6c84d 100644
--- 
a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassdifferentposition/Order.java
+++ 
b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassdifferentposition/Order.java
@@ -29,37 +29,37 @@ public class Order {
 
     // Positions of the fields start from 1 and not from 0
 
-    @DataField(pos = 1, position = 11)
+    @DataField(pos = 1, outPos = 11)
     private int orderNr;
 
-    @DataField(pos = 2, position = 10)
+    @DataField(pos = 2, outPos = 10)
     private String clientNr;
 
-    @DataField(pos = 3, position = 9)
+    @DataField(pos = 3, outPos = 9)
     private String firstName;
 
-    @DataField(pos = 4, position = 8)
+    @DataField(pos = 4, outPos = 8)
     private String lastName;
 
-    @DataField(pos = 5, position = 7)
+    @DataField(pos = 5, outPos = 7)
     private String instrumentCode;
 
-    @DataField(pos = 6, position = 6)
+    @DataField(pos = 6, outPos = 6)
     private String instrumentNumber;
 
-    @DataField(pos = 7, position = 5)
+    @DataField(pos = 7, outPos = 5)
     private String orderType;
 
-    @DataField(name = "Name", pos = 8, position = 4)
+    @DataField(name = "Name", pos = 8, outPos = 4)
     private String instrumentType;
 
-    @DataField(pos = 9, precision = 2, position = 3)
+    @DataField(pos = 9, precision = 2, outPos = 3)
     private BigDecimal amount;
 
-    @DataField(pos = 10, position = 2)
+    @DataField(pos = 10, outPos = 2)
     private String currency;
 
-    @DataField(pos = 11, pattern = "dd-MM-yyyy", position = 1)
+    @DataField(pos = 11, pattern = "dd-MM-yyyy", outPos = 1)
     private Date orderDate;
 
     public int getOrderNr() {

Reply via email to