Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:20:46+00:00 2026-05-27T06:20:46+00:00

I want to collect data which is classified in many groups. When I receive

  • 0

I want to collect data which is classified in many groups. When I receive the first item of a group, I want to put a boolean as TRUE, to indicate there is some info into that group or not.

My first approach was writing a method to return that boolean for each group I want to check. But since I have 8 groups, I though about giving a different scope: I defined an ENUM, and created a Map having that ENUM as key and the boolean as the Value:

enum dataNames{TITLE, AUTHOR, SOURCE, ELEVATION, SPEED, SATELLITES, LATITUDE, LONGITUDE}; //etc

private Map<dataNames, Boolean> availableData;

And then I check the state of each boolean calling this method:

public boolean isDataAvailable (dataNames name){
        return availableData.containsKey(name);
    }

For example:

public void addElevationValue(double elevationValue){
        if(!isDataAvailable(dataNames.ELEVATION)) availableData.put(dataNames.ELEVATION, true);
        elevacion.add(elevationValue);
    }

My question is: is this a good aproach, or should I stay with a method for each boolean I want to check? And… why? (I just want to learn)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:20:46+00:00Added an answer on May 27, 2026 at 6:20 am

    Why do you need a map to tell you if data is available or not?

    It looks like you are storing your data in a collection, so if this collection is empty, there is no data available.

    For example:

    public void addElevationValue(double elevationValue){
        elevacion.add(elevationValue);
    }
    
    public boolean hasElevationData(){
        return !elevacion.isEmpty();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a RESTful API for a website which will collect/insert/delete data
I want to collect some statistical data which needs some time to process, but
I want my C# program to collect data. Then, when the OK button is
I have the following situation: 2 swingworkers with session which collect data from the
To clarify: I want to collect data from from a hardware sensor and display
I'm developing an android application which is to collect data and then send it
I have a program in which I collect some data and store them temporarily
I have made a program in Java which is used to collect medical data
i have export a excel sheet which will collect data from my customer table
I have created HTA file which has userform to collect data from the user.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.