11/*
2- * Copyright (C) 2007-2017 , GoodData(R) Corporation. All rights reserved.
2+ * Copyright (C) 2007-2018 , GoodData(R) Corporation. All rights reserved.
33 * This source code is licensed under the BSD-style license found in the
44 * LICENSE.txt file in the root directory of this source tree.
55 */
66package com .gooddata .executeafm .afm ;
77
8+ import com .fasterxml .jackson .annotation .JsonCreator ;
9+ import com .fasterxml .jackson .annotation .JsonInclude ;
810import com .fasterxml .jackson .annotation .JsonProperty ;
911import com .fasterxml .jackson .annotation .JsonRootName ;
1012import com .gooddata .executeafm .ObjQualifier ;
1113import com .gooddata .executeafm .UriObjQualifier ;
1214import com .gooddata .util .GoodDataToStringBuilder ;
1315
1416import java .io .Serializable ;
15- import java .util .Objects ;
1617
1718import static com .gooddata .executeafm .afm .PopMeasureDefinition .NAME ;
1819
1920/**
2021 * Definition of so called "period over period" measure
2122 */
2223@ JsonRootName (NAME )
24+ @ JsonInclude (JsonInclude .Include .NON_NULL )
2325public class PopMeasureDefinition implements MeasureDefinition , Serializable {
2426
2527 private static final long serialVersionUID = 1430640153994197345L ;
@@ -29,21 +31,46 @@ public class PopMeasureDefinition implements MeasureDefinition, Serializable {
2931
3032 private final ObjQualifier popAttribute ;
3133
34+ private final Integer offset ;
35+
3236 /**
33- * Creates new definition from given measure identifier referencing another measure in {@link Afm} and given
34- * attribute qualifier (should qualify date attribute)
35- * @param measureIdentifier measure identifier
36- * @param popAttribute "period over period" date attribute
37+ * Creates new definition from given measure identifier referencing another measure in {@link Afm} and given attribute qualifier (should qualify date
38+ * attribute)
39+ *
40+ * @param measureIdentifier
41+ * measure identifier
42+ * @param popAttribute
43+ * "period over period" date attribute
44+ * @param offset
45+ * the number of periods the time window defined by {@code popAttribute} is offset about to the past (when value is negative) or future (when
46+ * value is positive)
3747 */
48+ @ JsonCreator
3849 public PopMeasureDefinition (@ JsonProperty ("measureIdentifier" ) final String measureIdentifier ,
39- @ JsonProperty ("popAttribute" ) final ObjQualifier popAttribute ) {
50+ @ JsonProperty ("popAttribute" ) final ObjQualifier popAttribute ,
51+ @ JsonProperty ("offset" ) final Integer offset ) {
4052 this .measureIdentifier = measureIdentifier ;
4153 this .popAttribute = popAttribute ;
54+ this .offset = offset ;
55+ }
56+
57+ /**
58+ * Creates new definition from given measure identifier referencing another measure in {@link Afm} and given attribute qualifier (should qualify date
59+ * attribute)
60+ *
61+ * @param measureIdentifier
62+ * measure identifier
63+ * @param popAttribute
64+ * "period over period" date attribute
65+ */
66+ public PopMeasureDefinition (final String measureIdentifier ,
67+ final ObjQualifier popAttribute ) {
68+ this (measureIdentifier , popAttribute , null );
4269 }
4370
4471 @ Override
4572 public MeasureDefinition withObjUriQualifier (final UriObjQualifier qualifier ) {
46- return new PopMeasureDefinition (measureIdentifier , qualifier );
73+ return new PopMeasureDefinition (measureIdentifier , qualifier , offset );
4774 }
4875
4976 /**
@@ -62,6 +89,15 @@ public ObjQualifier getPopAttribute() {
6289 return popAttribute ;
6390 }
6491
92+ /**
93+ * Returns number of periods defined via {@link #popAttribute} time interval.
94+ *
95+ * @return positive or negative number of periods or {@code null} when offset was not defined
96+ */
97+ public Integer getOffset () {
98+ return offset ;
99+ }
100+
65101 @ Override
66102 public ObjQualifier getObjQualifier () {
67103 return getPopAttribute ();
0 commit comments