Project

General

Profile

« Previous | Next » 

Revision 50676

using commons-lang3, using lambdas

View differences:

MDStoreUtils.java
11 11
public class MDStoreUtils {
12 12

  
13 13
	public static UnaryFunction<String, DBObject> mdId() {
14
		return new UnaryFunction<String, DBObject>() {
15

  
16
			@Override
17
			public String evaluate(final DBObject arg) {
18
				return (String) arg.get("mdId");
19
			}
20
		};
14
		return arg -> (String) arg.get("mdId");
21 15
	}
22 16

  
23 17
	public static UnaryFunction<Boolean, DBObject> dboFilter(final String format, final String layout, final String interpretation) {
24
		return new UnaryFunction<Boolean, DBObject>() {
25

  
26
			@Override
27
			public Boolean evaluate(final DBObject dbo) {
28
				return dbo.get("format").toString().equals(format) && dbo.get("layout").toString().equals(layout)
29
						&& dbo.get("interpretation").toString().equals(interpretation);
30
			}
31
		};
18
		return dbo -> dbo.get("format").toString().equals(format) && dbo.get("layout").toString().equals(layout)
19
				&& dbo.get("interpretation").toString().equals(interpretation);
32 20
	}
33 21

  
34 22
	public static Function<DBObject, String> body() {
35
		return new Function<DBObject, String>() {
36

  
37
			@Override
38
			public String apply(final DBObject dbo) {
39
				return (String) dbo.get("body");
40
			}
41
		};
23
		return dbo -> (String) dbo.get("body");
42 24
	}
43 25

  
44 26
	public static Comparator<DBObject> getComparatorOnDate() {
45
		return new Comparator<DBObject>() {
46

  
47
			@Override
48
			public int compare(final DBObject o1, final DBObject o2) {
49
				Date d1 = (Date) o1.get("date");
50
				Date d2 = (Date) o2.get("date");
51
				return d1.compareTo(d2);
52
			}
27
		return (o1, o2) -> {
28
			Date d1 = (Date) o1.get("date");
29
			Date d2 = (Date) o2.get("date");
30
			return d1.compareTo(d2);
53 31
		};
54 32
	}
55 33
}

Also available in: Unified diff