0
votes

I have a JSON configuration that lists events for each organization along with event config (when and where to schedule the event:

{
  "organizations": {
    
    "org-A" : {
      "events" : {
        "event-A" : {
          "venue": "blah",
          "date": "blah"
        }
      }
    },

    "org-B" : {
       ...
    }
    
  }
}

My current Java class for this config currently is:

public class OrgEventsConfig  {

   private final Map<String, Map<String, EventInfo>> config;

   @JsonIgnoreProperties(ignoreUnknown = true)
   static class EventInfo {
      private static final String venue;
      private static final Date eventDate;
   }
}

Is this encapsulation right? Should I include event name and organization in the event info?

How the information should be architected depends on your needs.Dave Newton
Refer Dave Newton's comment, that's how it should be. However, one point of observation is that you are using name of an attribute which actually should be a value. E.g. "org-A" is really a value (I don't know your full requirement). You could consider {"organizations":[{"orgName":"org-A","events"=[{"eventName":"event-A","venue"="v","date"="d"}]}]} ... but then I am not sure, if that's even feasible. As for the actual representation of the data, its completely dependent on your application requirements.Ironluca