0

I have a huge class with 500 members. Each member will have properties whether it can be Filled/Edited based on business logic .

public class Person{
public String firstName; 
//500 more Fields below
}

And similarly other 500 fields .

Consumer of the class will need whether the firstName can be Filled/Edited .

Straight forward way is

Enum FieldProperty{
CanBeEdited,CanBeFilled
}
public class Person{
public String firstName; 
List<FieldProperty> firstNameProperties = list(CanBeFilled)
//500 more Fields below
}

How to efficiently represent this ?

kcp
  • 33
  • 1
  • 7
  • Do these fill/edit properties vary between different instances of the class, or are they static? – Mauricio May 21 '22 at 04:36
  • Good question @Mauricio . They will vary for every instance . – kcp May 21 '22 at 04:37
  • that business logic that determines the state of these properties can be persisted, or is calculated only 'on the fly'? – Mauricio May 21 '22 at 04:48
  • It is computed on the fly based on the other members values. These properties are completely derivable based on the state . Hence i am looking for an efficient way . However the properties can change between fields . – kcp May 21 '22 at 04:58

1 Answers1

0

I am settling with below approach .

public class UiProperties<T>{
  Boolean CanBeEdited;
  Boolean CanBeFilled;
  Boolean CanBeDeleted;
}
public class Person{
public UiProperties<String> firstName; 
public UiProperties<String> lastName; 
public UiProperties<Date> dob; 
//500 more Fields below
}
kcp
  • 33
  • 1
  • 7