I have three methods.
-
The first method takes data from a List (which contains data objects specific to our my application), it then calls the second method, passing in the data it has acquired as parameters.
-
The second method then uses this information as a reference to take specific information from another list, calling the third method and passing this information to it as parameters.
-
The third method does the same as the second, using the data that is passed in as a reference to find specific data in a list.
Now the problem is, I want to use this information in a totally different method.
How should I go about calling my methods in order to get out the data?
private void getRecords() {
List<LabelSet> allSets = labelSetStructureService.getLabelSets();
for (LabelSet labelSet : allSets) {
List<LabelSet> groups = labelSetStructureService.getLabelGroupsForSet(labelSet.getId());
for (LabelGroup group : groups) {
getValuesForLabel(group.getCustomerMeasure(), labelSetStructureService.getLabelsForLabelGroup(group.getCustomer().getId(), group.getId()), labelSet);
}
}
}
private void getValuesForLabel(CustomerMeasure measure, List<Label> labels, LabelSet labelSet) {
for (Label label : labels) {
List<LabelSet> usageRecs = labelDataService.getLabelData(label, LabelSetStorage.DAY_BY_MONTH_STORAGE, new DateTime(), new DateTime().minusWeeks(1));
preProcessUsageRecs( usageRecs, labelSet);
}
}
private List<LabelUsage> preProcessUsageRecs(List<LabelUsage> usageRecs, LabelSet labelSet) {
//Format records, use list instead strings where possible
List<LabelSet> usageRecords = usageRecs; {
for( LabelUsage labelUsage : usageRecs)
usageRecords.addAll(usageRecs);
}
return usageRecords;
}
Java is an object based language, so use a member variable to store the result of that one call, like such that:
and then access
this.labelswherever you would need to use the result of this method;