ProductClassShape

slick.lifted.ProductClassShape
class ProductClassShape[E <: Product, C <: Product](val shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]], mapLifted: Seq[Any] => C, mapPlain: Seq[Any] => E)(implicit classTag: ClassTag[E]) extends MappedScalaProductShape[FlatShapeLevel, Product, C, E, C]

A generic Product class shape that can be used to lift a class of plain Scala types to a class of lifted types. This allows the type to be used as a record type (like tuples and HLists) in the Lifted Embedding.

This can help with mapping tables >22 columns to classes, especially when using code generation. This can be used for Scala 2.11 case classes >22 fields.

Example:

 def columnShape[T](implicit s: Shape[FlatShapeLevel, Column[T], T, Column[T]]) = s
 class C(val a: Int, val b: Option[String]) extends Product{
   def canEqual(that: Any): Boolean = that.isInstanceOf[C]
   def productArity: Int = 2
   def productElement(n: Int): Any = Seq(a, b)(n)
 }
 class LiftedC(val a: Column[Int], val b: Column[Option[String]]) extends Product{
   def canEqual(that: Any): Boolean = that.isInstanceOf[LiftedC]
   def productArity: Int = 2
   def productElement(n: Int): Any = Seq(a, b)(n)
 }
 implicit object cShape extends ProductClassShape(
   Seq(columnShape[Int], columnShape[Option[String]]),
   seq => new LiftedC(seq(0).asInstanceOf[Column[Int]], seq(1).asInstanceOf[Column[Option[String]]]),
   seq => new C(seq(0).asInstanceOf[Int], seq(1).asInstanceOf[Option[String]])
 )

Attributes

Source:
Shape.scala
Graph
Supertypes
class MappedScalaProductShape[FlatShapeLevel, Product, C, E, C]
class MappedProductShape[FlatShapeLevel, Product, C, E, C]
class ProductNodeShape[FlatShapeLevel, Product, C, E, C]
class Shape[FlatShapeLevel, C, E, C]
class Object
trait Matchable
class Any

Members list

Concise view

Type members

Inherited types

type Mixed = Mixed_

Attributes

Inherited from:
Shape
Source:
Shape.scala
type Packed = Packed_

Attributes

Inherited from:
Shape
Source:
Shape.scala
type Unpacked = Unpacked_

Attributes

Inherited from:
Shape
Source:
Shape.scala

Value members

Concrete methods

override def buildValue(elems: IndexedSeq[Any]): C

Build a record value represented by this Shape from its element values.

Build a record value represented by this Shape from its element values.

Attributes

Definition Classes
Source:
Shape.scala
override def copy(s: Seq[Shape[_ <: ShapeLevel, _, _, _]]): ProductClassShape[E, C]

Create a copy of this Shape with new element Shapes. This is used for packing Shapes recursively.

Create a copy of this Shape with new element Shapes. This is used for packing Shapes recursively.

Attributes

Definition Classes
Source:
Shape.scala
override def toMapped(v: Any): E

Attributes

Definition Classes
Source:
Shape.scala

Inherited methods

def buildParams(extract: Any => Unpacked): Packed

Build a packed representation containing QueryParameters that can extract data from the unpacked representation later. This method is not available for shapes where Mixed and Unpacked are different types.

Build a packed representation containing QueryParameters that can extract data from the unpacked representation later. This method is not available for shapes where Mixed and Unpacked are different types.

Attributes

Inherited from:
ProductNodeShape
Source:
Shape.scala
def encodeRef(value: Any, path: Node): Any

Encode a reference into a value of this Shape. This method may not be available for shapes where Mixed and Packed are different types.

Encode a reference into a value of this Shape. This method may not be available for shapes where Mixed and Packed are different types.

Attributes

Inherited from:
ProductNodeShape
Source:
Shape.scala
def getElement(value: Product, idx: Int): Any

Get the element value from a record value at the specified index.

Get the element value from a record value at the specified index.

Attributes

Inherited from:
MappedScalaProductShape
Source:
Shape.scala
override def getIterator(value: Product): Iterator[Any]

Get an Iterator of a record value's element values. The default implementation repeatedly calls getElement.

Get an Iterator of a record value's element values. The default implementation repeatedly calls getElement.

Attributes

Definition Classes
Inherited from:
MappedScalaProductShape
Source:
Shape.scala
def pack(value: Any): Packed

Convert a value of this Shape's (mixed) type to the fully packed type

Convert a value of this Shape's (mixed) type to the fully packed type

Attributes

Inherited from:
ProductNodeShape
Source:
Shape.scala

Return the fully packed Shape

Return the fully packed Shape

Attributes

Inherited from:
ProductNodeShape
Source:
Shape.scala
def toBase(v: Any): ProductWrapper

Attributes

Inherited from:
MappedProductShape
Source:
Shape.scala
override def toNode(value: Any): TypeMapping

Return an AST Node representing a mixed value.

Return an AST Node representing a mixed value.

Attributes

Definition Classes
Inherited from:
MappedProductShape
Source:
Shape.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns:

a string representation of the object.

Definition Classes
Inherited from:
ProductNodeShape
Source:
Shape.scala

Concrete fields

val shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]

The Shapes for the product elements.

The Shapes for the product elements.

Attributes

Source:
Shape.scala