Question: Is it possible to inherit a role in Java Servlet 3.0 and how? 

Let's say I have role A, B and C. In a servlet i have `if(request.isUserInRole("A")){ /* some feature only available for A */ }` and `if(request.isUserInRole("B")){ /* some feature only available for B */ }`. In web.xml are the roles defined:

```
<security-role>
    <role-name>A</role-name>
</security-role>
<security-role>
    <role-name>B</role-name>
</security-role>
<security-role>
    <role-name>C</role-name>
</security-role>

```

What I want is that every user with role C can do what A and B can without adding role A and B to user C.

Answer: 
One more approach I can suggest is a Builder Pattern

```
trait ElementBuilder {
  def identified(id: String): ElementBuilder
  def build: JQuery
}

case class DivElement(identifier: Option[String] = None) 
  extends ElementBuilder {
  def identified(id: String) = this.copy(identifier = Option(id))
  def build: JQuery = ??? // Smth like <div id={identifier}></div>
}

val builder = DivElement()
builder.identified("foo")
val element = builder.build

```

This approach allows you explicitly set parameters and then build you element by them
I would also go for a special string like the empty string in @Jiafeng's answer, if this is a sensible value. You could also define a string, like

```
val NoId = "?"

def div(id: String = NoId) = id match {
  case NoId => None
  case x    => Some(x)
}

```

Another approach would be to use another type which can be implicitly created from string or absence.

```
sealed trait MaybeId
implicit class Id(val name: String) extends MaybeId
case object NoId extends MaybeId

def div(id: MaybeId = NoId) = id match { 
  case NoId  => None
  case x: Id => Some(x.name)
}

```

---

[Here](https://github.com/Sciss/ScalaCollider/blob/master/src/main/scala/de/sciss/synth/Optional.scala) is a general type that behaves like `Option[A]` with implicit conversion `A => Some[A]`.