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 8641409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:31:04+00:00 2026-06-12T11:31:04+00:00

I have class BaseClass that contains a few methods like public Result mothodA(Token token,

  • 0

I have class BaseClass that contains a few methods like

public Result mothodA(Token token, String arg1, String arg2);

public Result mothodB(Token token, String arg1);

public OtherResult mothodC(Token token, String arg1, String arg2);

...

Is it possible to decorate this class somehow to pass automatically Token argument (which will be stored in decorator) ?

Expected output:

DecoratedBaseClass decorated = new DecoratedBaseClass();
Result result = decorated.methodA("arg1", "arg2");
OtherResult otherResult = decorated.methodC("arg1", "arg2");

I bet it’s not possible, but maybe I don’t know about some tricks with decorators.

  • 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-06-12T11:31:05+00:00Added an answer on June 12, 2026 at 11:31 am

    You change the interface of BaseClass so this has nothing to do with decorator its more an adapter.

    Decorator
    Attach additional responsibilities to an object dynamically keeping the same interface.

    Build a BaseClassAdapter and delegate the calls to BaseClass.

    public class BaseClassAdapter {
    
        private final BaseClass baseClass;
        private final Token token;
    
        public BaseClassAdapter(BaseClass baseClass){ 
           this.baseClass = baseClass;
           this.token = ...;
        }
    
        public Result mothodA(String arg1, String arg2) {
           baseClass.mothodA(token, arg1, arg2);
        }
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class Foo that is concrete and contains 30 methods which
I have abstract base class that contains some fields and some methods that act
I have a base class that contains the following events: public event EventHandler Loading;
I have a web service project that contains 3 classes: 1 Abstract public class
I have a class that inherits from a base class (this contains a lot
I have an abstract base class that holds a Dictionary. I'd like inherited classes
Assume some domain and view objects (that have no common base class) public class
I have a base class that contains a SqlDataReader which gets the data using
I'm constructing a fluent interface where I have a base class that contains the
I have 2 classses - PageScreen - Which is a base class that contains

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.