Skip to content

Commit

Permalink
spline #831 move methods from AttrOrExprRef case class to an implic…
Browse files Browse the repository at this point in the history
…it extension class to prevent Swagger from generating unwanted properties out of them.
  • Loading branch information
wajda committed Mar 25, 2021
1 parent 44bbd12 commit eb282ae
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ package za.co.absa.spline.producer.model.v1_1
* E.g. JSON object `{ __attrId: 42 }` represents a reference to an attribute with ID 42, while
* `{ _attrId: 42 }` or `{ __attrId: 42, foo: 1 }` represent arbitrary key-value pairs.
*
*
* @param __attrId attribute ID
* @param __exprId expression ID
*/
Expand All @@ -46,15 +45,17 @@ case class AttrOrExprRef(
require(
__attrId.isDefined ^ __exprId.isDefined,
s"Either `__attrId` or `__exprId` should be defined. Was: ${__attrId}, ${__exprId}")
}

def refId: ExpressionLike.Id = (__attrId orElse __exprId).get
object AttrOrExprRef {

def isAttribute: Boolean = __attrId.isDefined
implicit class AttrOrExprOps(val ref: AttrOrExprRef) extends AnyVal {
def refId: ExpressionLike.Id = (ref.__attrId orElse ref.__exprId).get

def isExpression: Boolean = __exprId.isDefined
}
def isAttribute: Boolean = ref.__attrId.isDefined

object AttrOrExprRef {
def isExpression: Boolean = ref.__exprId.isDefined
}

def attrRef(attrId: Attribute.Id): AttrOrExprRef = AttrOrExprRef(Option(attrId), None)

Expand Down

0 comments on commit eb282ae

Please sign in to comment.