2

多かれ少なかれ次のような POJO があります。

public class Action {
    private String eventId;
    private List<ActionArgument> arguments;
    //action to perform when this action is done
    private List<Action> onCompleteActions;

    public Action() {
    }

    public Action(String eventId, List<ActionArgument> arguments, List<Action> onCompleteActions) {
        this.eventId = eventId;
        this.arguments = arguments;
        this.onCompleteActions = onCompleteActions;
    }

    public String getEventId() {
        return eventId;
    }
    public void setEventId(String eventId) {
        this.eventId = eventId;
    }
    public List<ActionArgument> getArguments() {
        return arguments;
    }
    public void setArguments(List<ActionArgument> arguments) {
        this.arguments = arguments;
    }
    public List<Action> getOnCompleteActions() {
        return onCompleteActions;
    }
    public void setOnCompleteAction(List<Action> onCompleteActions) {
        this.onCompleteActions = onCompleteActions;
    }
}

そして、次のような拡張クラスがあります。

public class UserDefinedAction extends Action {
    //for reordering actions with the default actions
    private String doBefore;
    private String doAfter;
    private String doAfterComplete;

    public String getDoBefore() {
        return doBefore;
    }

    public void setDoBefore(String doBefore) {
        this.doBefore = doBefore;
    }

    public String getDoAfter() {
        return doAfter;
    }

    public void setDoAfter(String doAfter) {
        this.doAfter = doAfter;
    }

    public String getDoAfterComplete() {
        return doAfterComplete;
    }

    public void setDoAfterComplete(String doAfterComplete) {
        this.doAfterComplete = doAfterComplete;
    }
}

他の場所には、これをやりたいサービスがあります:

...
UserDefinedAction udAction = new UserDefinedAction();
udAction.setOnCompleteAction(new ArrayList<UserDefinedAction>());

UserDefinedActionIS はActionそれを正しく拡張しているので、これは機能するはずだと思いましたか?

4

2 に答える 2