Skip to content

Commit 1cd99db

Browse files
committed
allow construct ResultTotalHeaderItem from total type only
1 parent 83487bb commit 1cd99db

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/main/java/com/gooddata/executeafm/result/ResultTotalHeaderItem.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ public class ResultTotalHeaderItem extends ResultHeaderItem {
2424

2525
private final String type;
2626

27+
/**
28+
* Creates new instance of given total type, type is used for the name as well
29+
* @param type total type
30+
*/
31+
public ResultTotalHeaderItem(final String type) {
32+
this(type, type);
33+
}
34+
35+
/**
36+
* Creates new instance of given total type, type is used for the name as well
37+
* @param type total type
38+
*/
39+
public ResultTotalHeaderItem(final Total type) {
40+
this(notNull(type, "type").toString());
41+
}
42+
2743
/**
2844
* Creates new instance of given header name and total type
2945
* @param name header name

src/test/groovy/com/gooddata/executeafm/result/ResultTotalHeaderItemTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,16 @@ class ResultTotalHeaderItemTest extends Specification {
3232
item.name == 'Some total'
3333
item.type == 'avg'
3434
}
35+
36+
def "should create from type only"() {
37+
expect:
38+
with(new ResultTotalHeaderItem('avg')) {
39+
name == 'avg'
40+
type == 'avg'
41+
}
42+
with(new ResultTotalHeaderItem(Total.SUM)) {
43+
name == 'sum'
44+
type == 'sum'
45+
}
46+
}
3547
}

0 commit comments

Comments
 (0)