Question: This is my following code:

```
$this->db->where('plb_db_prod.tpb_header.KODE_DOKUMEN_PABEAN = 27 AND plb_db_prod.tpb_header.KODE_KANTOR_TUJUAN = 050100 OR plb_db_prod.tpb_header.KODE_DOKUMEN_PABEAN = 40 OR plb_db_prod.tpb_header.KODE_DOKUMEN_PABEAN = 16');

$this->db->where('plb_db_prod.tpb_header.TANGGAL_AJU >= '.$start_date.' AND plb_db_prod.tpb_header.TANGGAL_AJU <= '.$end_date);

```

Answer: 
Here's is a more concise, perhaps a bit less intimidating version of Sarvesh Kumar Singh's suggestion to use a typeclass. I think that is the best approach all around. It gives you typesafe functionality while letting you keep your basic types very simple.

```
trait Figure {
  def x:Int
  def y:Int
}
case class Circle(x:Int, y: Int, radius: Double) extends Figure

case class Rectangle(x:Int, y: Int, width: Int, height: Int) extends Figure

trait Movable[T] {
  def move( x: Int, y: Int, movable: T ) : T
}
implicit final object CircleIsMovable  extends Movable[Circle] {
  def move( x: Int, y: Int, c: Circle ) = Circle( c.x + x, c.y + y, c.radius )
}
implicit final object RectangleIsMovable  extends Movable[Rectangle] {
  def move( x: Int, y: Int, r: Rectangle ) = Rectangle( r.x + x, r.y + y, r.width, r.height )
}
object Motor {
  def move[T : Movable](x: Int, y: Int, movable: T) : T = implicitly[Movable[T]].move( x, y, movable )
}

```

Then...

```
scala> Motor.move(10,10,Circle(0,0,1))
res1: Circle = Circle(10,10,1.0)

scala> Motor.move(10,10,Rectangle(0,0,1,1))
res2: Rectangle = Rectangle(10,10,1,1)

```
Maybe what you are after is something like

```
object Motor {
  def move[T <: Figure](x: Int, y: Int, figure: T): T = {
    val moved = figure match {
      case Circle(xPos, yPos, radio) => Circle(xPos+x, yPos+y, radio)          
      case Rectangle(xPos, yPos, width, high) => Rectangle(xPos+x, yPos+y, width, high)
    }
    moved.asInstanceOf[T]
  }
}

```