Questions tagged [case-class]

Case classes are regular classes which export their constructor parameters and which provide a recursive decomposition mechanism via pattern matching.

711 questions
-1
votes
1 answer

override case class method in scala

I am trying to override a method of trait in my case class which want to display all the members of case class. I am using it for debugging purpose. trait A{ def myMethod(employee:Emp):Unit } case class Emp(id:String,name:String) extends A { …
coder25
  • 2,363
  • 12
  • 57
  • 104
-1
votes
2 answers

Scala case class fields

I'm trying to understand a Scala case class difference with a regular class. E.g. I have a definition case class Charge(cc: CreditCard, amount: Double) and can use it like carge.cc and charge.amount. Are these statements constant field references or…
Andriy Kryvtsun
  • 3,220
  • 3
  • 27
  • 41
-1
votes
2 answers

How to check if case class parameter has value or not in Scala

I have a case class QueryParamsas follows: case class QueryParams( limit: Option[Integer] = None, refresh: Option[Boolean] = None, organisationalUnit: Option[String] = None) These values limit,refresh,organisationalUnit are actually passed as query…
b1399877
  • 27
  • 2
  • 6
-1
votes
1 answer

scala rename case class property dynamically

I have an object object Helper{ val fieldName = "fooBar } which provides the name for a field. And a case class case class BarBaz(fieldOne:Int, fieldTwo:String) But instead of fieldTwo, I would like to refer to Helper.fieldname for the parameter…
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292
-1
votes
1 answer

Scala case class instantiate when you have not-used-in-equals properties

Have an academic class: case class A3(name: String)(val s: String) {} Trying to instantiate it. I tried val v = A3("la") val v = A3("la", "ba") Neither worked. Looked at a book,…
tgkprog
  • 4,493
  • 4
  • 41
  • 70
-1
votes
1 answer

Internal case class in scala

I have the following case class case class MyClass (LeftHandSide: (Set[String], String), RightHandSide: Double) so, I can do the following MyClass((Set("yu", "ye"), "bee"), 0.03).filter( x=> x.RightHandSide>4) and I would like to able to call…
-1
votes
1 answer

Scala case classes and inheritance

My knowledge is a little bit vague on Scala's case classes. I know that case classes automatically get functions such as appply and unapply and also an equality check (I'm assuming it's the equals method) The automatic equality check that comes with…
Anton
  • 2,282
  • 26
  • 43
-1
votes
3 answers

searching on a List Of Case Class

i need to search on a list of case class example:in below example i want to know that teamList contains name=php or not. scala> case class Team(name: String, image: String, nMember: BigInt, nYear: BigInt) defined class Team scala> val…
Govind Singh
  • 15,282
  • 14
  • 72
  • 106
-2
votes
2 answers

Can we convert option[string] to caseclass in scala?

When I tried to convert Some(string) into a case class I am getting an exception. Ex: val a:option[string]= Some("abc") case class hello(a:string) a.get.convertto[hello] => it is showing error
Hola Hola
  • 9
  • 2
-2
votes
1 answer

Custom annotations in scala

I am working in Scala programming language. I want to create custom annotations to annotate the fields of case class. this thread show how to create it but there are two problems I am facing for my scenario There can be . in the annotations. e.g.…
user10360768
  • 225
  • 3
  • 14
-2
votes
1 answer

Dynamic assignment of case class in a class declaration

We have two case classes which has different parameters. For Example - case class OneType(@JsonProperty("column1") column1 : String, @JsonProperty("column2") column2 : Map[String,Any], @JsonProperty("column3")…
Pralay Ghosh
  • 15
  • 1
  • 2
  • 10
-2
votes
1 answer

Need to add tuple in case class variable under condition

I have a case class as case class Attendance(List(name,totalDay)) and i have three variable val ana = 0 val mario = 33 val romero = 11 I have to create the object of attendance class such as they have name and attendance only if attendance is…
user7097216
-2
votes
1 answer

iterate through list of list and collect elements to a string

I have a nested list structure and I want to iterate through the list and print the custom string version of it trait Value{ def myString:String } case class Student(value: String) extends Value{ override def myString:…
coder25
  • 2,363
  • 12
  • 57
  • 104
-2
votes
1 answer

Scala: importance during implementation of case class private

I understand that using something like case class private A() new A()#This will be a invalid call as A is private But what I do not understand that as from an implementation perspective, what advantage does this provide while coding? Because…
Viraj Rai
  • 75
  • 2
-2
votes
1 answer

Access members of case class

I have a case class defined in a scala companion object. case class ResponseSuccess(resp: SMPPSubmitSMResp) Which I send to an akka-actor (Java) if(res.isRight) sender ! Backend.ResponseSuccess(sms.resp) It is received like this, but I don't know…
FelixHJ
  • 1,071
  • 3
  • 12
  • 26
1 2 3
47
48