Skip to content

Commit

Permalink
chore(quality): [eclipse-tractusx#841] simplify builder for EdcReceiv…
Browse files Browse the repository at this point in the history
…erException

single field builder and private setters in the class are sufficient here and reduce amount of boilerplate code
  • Loading branch information
dsmf committed Jul 31, 2024
1 parent a95e960 commit f2d88aa
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
********************************************************************************/
package org.eclipse.tractusx.irs.registryclient.decentral;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;

/**
* Thrown in case of error in EDC communication
*/
@Getter
@Setter(AccessLevel.PRIVATE)
public class EdcRetrieverException extends Exception {

private String bpn;
Expand All @@ -40,36 +43,29 @@ public EdcRetrieverException(final Throwable cause) {
super(cause);
}

private EdcRetrieverException(final Builder builder) {
super(builder.cause);
this.bpn = builder.bpn;
this.edcUrl = builder.edcUrl;
}

/**
* Builder for {@link EdcRetrieverException}
*/
public static class Builder {
private final Throwable cause;
private String bpn;
private String edcUrl;

private final EdcRetrieverException exception;

public Builder(final Throwable cause) {
this.cause = cause;
this.exception = new EdcRetrieverException(cause);
}

public Builder withBpn(final String bpn) {
this.bpn = bpn;
this.exception.setBpn(bpn);
return this;
}

public Builder withEdcUrl(final String edcUrl) {
this.edcUrl = edcUrl;
this.exception.setEdcUrl(edcUrl);
return this;
}

public EdcRetrieverException build() {
return new EdcRetrieverException(this);
return this.exception;
}
}

Expand Down

0 comments on commit f2d88aa

Please sign in to comment.