trait Structural[Mixin] extends Serializable
A type class that converts a class type to a refinement type
This Structural type class provides an extension method structuralize via implicit view, which can be import as follow:
import com.thoughtworks.feature.Structural.ops._
- Source
- Structural.scala
Given a class that contains abstract types:
trait Container extends Iterable[String] { trait InnerApi type Inner <: InnerApi def inner: Inner = ??? type Self0 >: this.type def self: Self0 = this } val container: Container = new Container { def iterator = Iterator.empty }
When converting it to a structural type
import scala.language.higherKinds val myStruct = container.structuralize
Then methods on the converted struct should be able to access via reflective call
import scala.language.reflectiveCalls myStruct.self should be(myStruct)
, Given a String
val myString: String = "foo"
When converting it to a structural type
val myStruct = myString.structuralize
Then methods on the converted struct should be able to access via reflective call
import scala.language.reflectiveCalls myStruct.startsWith("f") should be(true)
However, the struct is not a String
"myStruct: String" shouldNot typeCheck
Examples:
Linear Supertypes
Type Hierarchy
Ordering
- Alphabetic
- By Inheritance
Inherited
- Structural
- Serializable
- Serializable
- Any
Implicitly
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
Visibility
- Public
- All
Type Members
- abstract type Out >: Mixin
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to any2stringadd[Structural[Mixin]] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (Structural[Mixin], B)
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to ArrowAssoc[Structural[Mixin]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
ensuring(cond: (Structural[Mixin]) ⇒ Boolean, msg: ⇒ Any): Structural[Mixin]
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to Ensuring[Structural[Mixin]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (Structural[Mixin]) ⇒ Boolean): Structural[Mixin]
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to Ensuring[Structural[Mixin]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Structural[Mixin]
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to Ensuring[Structural[Mixin]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): Structural[Mixin]
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to Ensuring[Structural[Mixin]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
equals(arg0: Any): Boolean
- Definition Classes
- Any
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to StringFormat[Structural[Mixin]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
def
hashCode(): Int
- Definition Classes
- Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def structuralize(mixin: Mixin): Out
-
def
toString(): String
- Definition Classes
- Any
-
def
→[B](y: B): (Structural[Mixin], B)
- Implicit
- This member is added by an implicit conversion from Structural[Mixin] to ArrowAssoc[Structural[Mixin]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc