Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor org.dcm4che3.audit.XXXXBuilder classes #894

Closed
gunterze opened this issue Feb 8, 2021 · 0 comments
Closed

Refactor org.dcm4che3.audit.XXXXBuilder classes #894

gunterze opened this issue Feb 8, 2021 · 0 comments
Assignees
Milestone

Comments

@gunterze
Copy link
Member

gunterze commented Feb 8, 2021

Refactor org.dcm4che3.audit.XXXXBuilder classes by flatting inner class Builder with containing top level class and provide method returning the built object.

Particularly, replace

public class EventIdentificationBuilder {
    final AuditMessages.EventID eventID;
    final String eventActionCode;
    final Calendar eventDateTime;
    final String outcome;
    final String outcomeDesc;
    final EventTypeCode[] eventTypeCode;

    public static class Builder {
        private final AuditMessages.EventID eventID;
        private final String eventActionCode;
        private final Calendar eventDateTime;
        private final String outcome;
        private String outcomeDesc;
        private EventTypeCode[] eventTypeCode = {};

        public Builder(AuditMessages.EventID eventID, String eventActionCode, Calendar eventDateTime, String outcome) {
            this.eventID = eventID;
            this.eventActionCode = eventActionCode;
            this.eventDateTime = eventDateTime;
            this.outcome = outcome;
        }

        public Builder outcomeDesc(String val) {
            outcomeDesc = val;
            return this;
        }

        public Builder eventTypeCode(EventTypeCode... val) {
            eventTypeCode = val;
            return this;
        }

        public EventIdentificationBuilder build() {
            return new EventIdentificationBuilder(this);
        }
    }

    private EventIdentificationBuilder(Builder builder) {
        eventID = builder.eventID;
        eventActionCode = builder.eventActionCode;
        eventDateTime = builder.eventDateTime;
        outcome = builder.outcome;
        outcomeDesc = builder.outcomeDesc;
        eventTypeCode = builder.eventTypeCode;
    }
}

by

public class EventIdentificationBuilder {
    private final AuditMessages.EventID eventID;
    private final String eventActionCode;
    private final Calendar eventDateTime;
    private final String outcome;
    private String outcomeDesc;
    private EventTypeCode[] eventTypeCode = {};

    public EventIdentificationBuilder(AuditMessages.EventID eventID, String eventActionCode, Calendar eventDateTime,
            String outcome) {
        this.eventID = eventID;
        this.eventActionCode = eventActionCode;
        this.eventDateTime = eventDateTime;
        this.outcome = outcome;
    }

    public EventIdentificationBuilder outcomeDesc(String val) {
        outcomeDesc = val;
        return this;
    }

    public EventIdentificationBuilder eventTypeCode(EventTypeCode... val) {
        eventTypeCode = val;
        return this;
    }

    public EventIdentification build() {
        EventIdentification ei = new EventIdentification();
        ei.setEventID(eventID);
        ei.setEventActionCode(eventActionCode);
        ei.setEventDateTime(eventDateTime);
        ei.setEventOutcomeIndicator(outcome);
        ei.setEventOutcomeDescription(outcomeDesc);
        for (org.dcm4che3.audit.EventTypeCode type : eventIdentificationBuilder.eventTypeCode)
            ei.getEventTypeCode().add(type);
        return ei;
    }
}

and apply analogous changes to classes ActiveParticipantBuilder, ParticipantObjectDescriptionBuilder and ParticipantObjectIdentificationBuilder.

@gunterze gunterze added this to the 5.23.1 milestone Feb 8, 2021
@gunterze gunterze assigned vrindanayak and gunterze and unassigned vrindanayak Feb 8, 2021
gunterze added a commit to dcm4che/dcm4chee-arc-light that referenced this issue Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants