forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetric.java
More file actions
65 lines (54 loc) · 1.83 KB
/
Metric.java
File metadata and controls
65 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata.md;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Metric
*/
@JsonTypeName("metric")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Metric extends Obj implements Queryable {
@JsonProperty("content")
private final Content content;
@JsonCreator
private Metric(@JsonProperty("meta") Meta meta, @JsonProperty("content") Content content) {
super(meta);
this.content = content;
}
public Metric(String title, String expression, String format) {
this(new Meta(title), new Metric.Content(expression, format));
}
@JsonIgnore
public String getExpression() {
return content.getExpression();
}
@JsonIgnore
public String getFormat() {
return content.getFormat();
}
@JsonIgnoreProperties(ignoreUnknown = true)
private static class Content {
private final String expression;
private final String format;
@JsonCreator
public Content(@JsonProperty("expression") String expression, @JsonProperty("format") String format) {
this.expression = expression;
this.format = format;
}
public String getExpression() {
return expression;
}
public String getFormat() {
return format;
}
}
}