Skip to content

Commit 8f9b551

Browse files
committed
Merge pull request #41 from hossein761/master
IndexUtils can now convert UUIDs
2 parents cb1f74d + 794821c commit 8f9b551

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

module/app/com/github/cleverage/elasticsearch/IndexUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import play.Logger;
55

66
import java.math.BigDecimal;
7-
import java.util.ArrayList;
8-
import java.util.Date;
9-
import java.util.List;
10-
import java.util.Map;
7+
import java.util.*;
118

129
public abstract class IndexUtils {
1310

@@ -128,6 +125,9 @@ else if (targetType.equals(Float.class)) {
128125
return Float.valueOf(value.toString());
129126
}
130127
}
128+
else if (targetType.equals(UUID.class)) {
129+
return UUID.fromString((String) value);
130+
}
131131
else {
132132
return value;
133133
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.github.cleverage.elasticsearch;
2+
3+
import org.junit.Test;
4+
5+
import java.util.UUID;
6+
7+
import static org.junit.Assert.assertEquals;
8+
9+
/**
10+
*
11+
* @author Hossein Kazemi
12+
*/
13+
public class IndexUtilsTest {
14+
@Test
15+
public void shouldConvertValue() throws Exception {
16+
UUID uuid = UUID.randomUUID();
17+
String uuidString = uuid.toString();
18+
UUID conversionResult= (UUID) IndexUtils.convertValue(uuidString, UUID.class);
19+
assertEquals(uuid, conversionResult);
20+
}
21+
}

0 commit comments

Comments
 (0)