webpush-java icon indicating copy to clipboard operation
webpush-java copied to clipboard

How can I pass Subscription.Keys to Subscription constructor if Keys is nested class?

Open TorosyanV opened this issue 6 years ago • 3 comments

Maybe will be good to move

public class Keys {
    public String p256dh;
    public String auth;

    public Keys() {
    }

    public Keys(String p256dh, String auth) {
      this.p256dh = p256dh;
      this.auth = auth;
    }
  }

to Keys.java class

TorosyanV avatar May 16 '18 18:05 TorosyanV

I can use

OuterClass.InnerClass innerObject = outerObject.new InnerClass();

But I think it's not a good pracites

TorosyanV avatar May 16 '18 18:05 TorosyanV

Thanks for your feedback! I created this as an inner class because I use Gson to deserialize a JSON string to a subscription. If I recall correctly, to deserialize a JSON string with nested objects Gson requires nested classes. I can check if this is still the case and refactor this if possible, but I don't consider this a big issue.

martijndwars avatar May 17 '18 07:05 martijndwars

@MartijnDwars In my scenario I'm saving keys in database and need to be manually set values.

TorosyanV avatar May 30 '18 18:05 TorosyanV