googleads / googleads-java-lib

Google Ad Manager SOAP API Client Library for Java
Apache License 2.0
226 stars 361 forks source link

Why there is no non-parameterized constructor for certain classes #134

Closed Padmahas closed 6 years ago

Padmahas commented 6 years ago

Hello,

We noticed some classes doesn't have non-parameterized constructor such as

  1. com.google.api.ads.dfp.axis.v201708.GoalType;
  2. com.google.api.ads.dfp.axis.v201708.UnitType;
  3. TimeUnit etc

In some situation, I need to copy GoalType object to custom GoalType object using BeanUtils.copyProperties. Since GoalType doesn't have non-parameterized constructor, I need to initialize GoalType object to null. GoalType goalTy = null;

If I try to copy using BeanUtils to this null object, it will throw exception. "Target must not be null". BeanUtils.copyProperties(lineItemObj.getPrimaryGoal().getGoalType(), goalTy);

Is there is any specific reason for not to provide non-parameterized constructor?

Thank you.

christopherseeley commented 6 years ago

Yes, these are meant to represent enumerations and should not be null. However, the axis stub generation doesn't actually create these as Java enums, so the code is a little messy.

An alternative might be using the dfp_appengine module instead, which has properly generated Java enums.

If you're set on using the axis library, then you probably need to register a custom Converter.