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 java/jni path model element #25494

Open
yunhanw-google opened this issue Mar 6, 2023 · 1 comment
Open

Refactor java/jni path model element #25494

yunhanw-google opened this issue Mar 6, 2023 · 1 comment
Assignees
Labels
java Issues in java-matter-controller stale Stale issue or PR

Comments

@yunhanw-google
Copy link
Contributor

          Not blocking this PR, but it seems we are repeating this pattern of a triple of endpoint / cluster / <target: attribute / command ID> all over for read/write/subscribe/invoke which ends up propagating into several overloads for raw integers vs object wrappers. Perhaps we could refactor this into a containing object with a builder that takes integer vs object for each property? Something like:
public final class InteractionTarget {
  private final ChipPathId endpointId;
  private final ChipPathId clusterId;
  private final ChipPathId targetId;

  public static final class Builder {
    private ChipPathId endpointId = ChipPathId.forWildcard();
    private ChipPathId clusterId = ChipPathId.forWildcard();
    private ChipPathId targetId = ChipPathId.forWildcard();
 
    public Builder setEndpointId(int endpointId) {
      this.endpointId = ChipPathId.forId(endpointId);
      return this;
    }

    public Builder setEndpointId(ChipPathId endpointId) {
      this.endpointId = endpointId;
      return this;
    }

    // Same for clusterId and targetId

    public InteractionTarget build() {
      return new InteractionTarget(endpointId, clusterId, targetId);
    }
  }
}

This way each of these Element classes can just take in an InteractionTarget and not have to require so many overloads.

Originally posted by @g-coppock in #25476 (comment)

@yunhanw-google yunhanw-google self-assigned this Mar 6, 2023
@bzbarsky-apple bzbarsky-apple added the java Issues in java-matter-controller label Mar 6, 2023
@stale
Copy link

stale bot commented Oct 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Issues in java-matter-controller stale Stale issue or PR
Projects
Status: Todo
Development

No branches or pull requests

2 participants