Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Do you have a plan to support abstract class? #5

Open
kenchan0130 opened this issue Aug 2, 2018 · 7 comments
Open

Do you have a plan to support abstract class? #5

kenchan0130 opened this issue Aug 2, 2018 · 7 comments

Comments

@kenchan0130
Copy link

kenchan0130 commented Aug 2, 2018

I'd like to use masking feature even in abstract class (or sealed abstract class) and I know if this library only supports case class.

Do you have a plan to support it in this library?

@kciesielski
Copy link
Member

@kenchan0130 Do you mean something like:

@customize
abstract class RootClass

case class Child(@mask field: String)

?

@kenchan0130
Copy link
Author

kenchan0130 commented Aug 16, 2018

@kciesielski

For example,

@customize
sealed abstract class RootClass(@mask val value: String)

case object Child1 extends RootClass("child1")
case object Child2 extends RootClass("child2")

like this.

@kciesielski
Copy link
Member

I see, thanks. An interesting case, I'll try to look into implementing it. What kind of data do you store in the "value" field? I'm asking because I'm curious what needs to be masked from toString which is, at the same time, hardcoded in the sources.

@kenchan0130
Copy link
Author

kenchan0130 commented Aug 16, 2018

I'm so sorry.
That example was not concrete.

trait SomeLibraryTrait[T] {
  val value: T
  override def toString() = value.toString()
}

@customize
abstract class EmployeePrivateInfo(@mask val value: Int) extends SomeLibraryTrait[Int]

case object Bachelor extends EmployeePrivateInfo(1)
case object AlreadyMarried extends EmployeePrivateInfo(2)

Specifically, it is here.
Suppose that SomeLibraryTrait is an uncontrolled trait provided by a library and so on.

Certainly, I can also create custom trait with masking string like:

trait MaskTrait[T] extends SomeLibraryTrait[T] {
  override val value: T
  override def toString() = "*****"
}

// Without using stringmask library
abstract class EmployeePrivateInfo(val value: Int) extends MaskTrait[Int]

case object Bachelor extends EmployeePrivateInfo(1)
case object AlreadyMarried extends EmployeePrivateInfo(2)

@kciesielski
Copy link
Member

I see, but still the masked values 1 and 2 are hardcoded. What business case can be modeled with hardcoded constant values which need to be masked in toString? Are these some keys or other kinds of identifiers?

@kenchan0130
Copy link
Author

I have the case I want to mask in a complex situation.

In the case where it is important personal information when two items are combined,
I want to mask some strings
For example,

case class Employee(name: EmployeeName, privateInfo: EmployeePrivateInfo)

Of course, because of the different responsibilities, there may be some opinion that it should be marked on the upper layer like:

@customize
case class Employee(name: EmployeeName, @mask privateInfo: EmployeePrivateInfo)

However, in this case, some developers may forget to mask value because EmployeePrivateInfo is not primitive value.

@kciesielski
Copy link
Member

Thanks for explaining. I can see how supporting abstract classes fits to this case. I will look into supporting abstract classes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants