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

  • SEARCH
  • Home
  • 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 7617779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:13:58+00:00 2026-05-31T03:13:58+00:00

I’m building a rest interface in an existing project. The project has a class

  • 0

I’m building a rest interface in an existing project. The project has a class that defines about 4 different types of operations. Each operation takes a different type of object to define the query parameters. Each operation returns a different type of object, all of which are XML jaxb encoded objects and end up getting marshalled to an OutputStream.

I am parsing parameters out of the URL and building the query objects required for the various operations. Currently, I have an abstract Query parent class, a QueryFactory class that switches between query types and returns a child Query class specific to the type of request in the URL. All the child query classes implement an abstract “buildQueryParameters” method and get the result as an Object type.

Is that as good as it gets? Is there some fancy way to use parameterized types or generic classes to build my query parameters objects? I find myself building these switch statements all over my code to differentiate between the request types and I’m not sure if that’s the best way…

Edit:

I’m subclasses because my servlet code looks like this:

Query query = QueryFactory.getInstance(parameterMap, requestEnum);
query.buildQueryParams();
Object queryParams = query.getQueryParams();

Query factory is pretty straight forward:

 public static Query getInstance(Map<String, String> parameterMap, RequestEnum requestEnum) {
        switch (requestEnum) {
            case GETSTATUS: {
                return new GetStatusQuery(parameterMap);
            }
            case DESCRIBEOPS: {
                return new DescribeOpsQuery(parameterMap);
            }
            case GETSTATUSBYID: {
                return new GetStatusByIdQuery(parameterMap);
            }
            case GETEVENTS: {
                return new GetEventsQuery(parameterMap);
            }
            default:
                break;
        }
        return null;
    }

The abstract Query class is also boring:

public abstract class Query {

    protected Map<String, String> validatedMap;
    private Object queryParams;

    public SOSQuery(Map<String, String> parameterMap) {
            this.parameterMap = parameterMap;
        }

        public Object getQueryParams() {
            return this.queryParams;
        }

        public abstract void buildQueryParams();

        protected void setQueryParams(Object queryParams) {
            this.queryParams = queryParams;
        }

        protected Map<String, String> getParameterMap() {
            return this.parameterMap;
        }

Each child class implements the buildQueryParams() method and creates the specific objects required for each different type of request/operation and returns them as objects, which the marshaller has no problem handling, so I don’t necessarily need to be more specific with the return types.

  • 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-31T03:13:59+00:00Added an answer on May 31, 2026 at 3:13 am

    you can declare public abstract class SOSQuery<T> { and then private T queryParams;

    public T getQueryParams() {
        return this.queryParams;
    }
    

    and so on …

    for the subclasses you would declare

    public class GetStatusQuery extends SOSquery<GetStatusParticularType> {
    

    is this what you need?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.