@startuml
!unquoted function $textColor($parameter, $color="red")
  '$color= Red, Blue, Green,...
  !return %chr(34) + "<color:" + $color + ">" + $parameter + "</color>" +%chr(34)
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClass($classType="", $name="", $stereotype="", $color="")
  !local $aux = %lower($classType)

  !if ($aux != "" || %lower($aux) != "abstract")
    !$classType = ""
  !endif

  !if ($name == "")
    !$name = $textColor("name", "Red")
  !endif

  !return $classType + " class " + $name + " " + $stereotype + $color +" {"
!endfunction
'--------------------------------------------------------------------------------
!function $defClassEnd()
  !return "}"
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClassAttribute($visibility = "-", $name="" , $dataType = "T", $displaylabel="", $defaultValue = "", $pk = "FALSE", $unique = "FALSE", $required = "FALSE", $hidden = "FALSE", $calculate = "", $constraint = "")
  !local $aux = $visibility

  !if ($name == "")
    !$aux = $aux + $textColor("missingAttribute","red")
  !else
    !$aux = $aux + $name
  !endif

  !if ($dataType != "")
    !$aux = $aux + " :" + $dataType
  !endif

  !if ($defaultValue != "")
    !$aux = $aux + ' = "' + %string($defaultValue) + '"'
  !endif

  !if  (%lower($pk) == "true")
    !$aux = $aux + " {PK}"
  !endif

  !if (%lower($unique) == "true")
    !$aux = $aux + " {unique}"
  !endif

  !if (%lower($required) == "true")
    !$aux = $aux + " {required}"
  !endif

  !if (%lower($hidden) == "true")
    !$aux = $aux + " {hidden}"
  !endif

  !if ($calculate != "")
    !$aux = $aux +  ' {calculate = "' + $calculate + '"}'
  !endif

  !if ($constraint != "")
    !$aux = $aux + ' {constraint = "' + $constraint + '"}'
  !endif

  !return $aux
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClassSetWhere($logicOper="NONE", $condition="")
  !local $aux = '+ setWhere( "'

  !if (%upper($logicOper) == "NONE")
    !$logicOper = ""
  !endif

  !if (%lower($logicOper) == "and" || %lower($logicOper) == "or" || $logicOper == "")
    !if ($logicOper != "" && $condition != "")
      !$aux = $aux + $logicOper + " " + $condition
    !elseif ($logicOper == "" && $condition != "")
      !$aux = $aux + $condition
    !elseif ($logicOper != "" && $condition == "")
      !$aux = $aux + "**errorMissingCondition**"
    !endif
  !else
    !$aux = $aux + "**errorLogicOper**"
  !endif

  !return $aux + '" ) :void'
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClassSetOrderBy($columnList="")
  !local $aux = '+ setOrderBy( "'
  !$aux = $aux + $columnList
  !return $aux + '" ) :void'
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClassSetGroupBy($columnList="")
  !local $aux = '+ setGroupBy( "'
  !$aux = $aux + $columnList
  !return $aux + '" ) :void'
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClassSetHaving($condition="")
  !local $aux = '+ setHaving( "'
  !$aux = $aux + $condition
  !return $aux + '" ) :void'
!endfunction
'--------------------------------------------------------------------------------
!unquoted function $defClassSetParameter($methodName="", $parameterName="", $dataType="T" )
  !local $aux = '- <<input>> '
  !$aux = $aux + $methodName + '('
  !$aux = $aux + $parameterName
  !$aux = $aux + ' :' + $dataType
  !return $aux + ') :void'
!endfunction
@enduml
