Skip to content

Make *(one|zero) weights singletons#153

Merged
swissiety merged 10 commits intodevelopfrom
fix/make-one-zero-weights-singletons
May 6, 2025
Merged

Make *(one|zero) weights singletons#153
swissiety merged 10 commits intodevelopfrom
fix/make-one-zero-weights-singletons

Conversation

@Hazem-Gamall
Copy link
Member

@Hazem-Gamall Hazem-Gamall commented May 6, 2025

Close #150

@Hazem-Gamall Hazem-Gamall requested review from Copilot and swissiety May 6, 2025 11:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR standardizes the implementation of several weight and transition function classes by enforcing the singleton pattern, ensuring that only a single instance (one or zero) exists. Key changes include making public constructors private, adding @nonnull annotations on parameters, and updating string representations in toString methods.

  • TransitionFunctionZero.java & TransitionFunctionOne.java: Constructors changed to private to enforce singleton usage and NonNull annotations added where needed.
  • PathConditionWeightOne.java, MinDistanceWeightOne.java, DataFlowPathWeightOne.java, SetDomainZero.java, SetDomainOne.java: Constructors made private in line with the singleton approach.
  • MinDistanceWeightImpl.java: Simplified the toString method by removing an instantiation of the singleton weight.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
idealPDS/src/main/java/typestate/TransitionFunctionZero.java Constructor changed to private to enforce singleton
idealPDS/src/main/java/typestate/TransitionFunctionOne.java Constructor made private and NonNull annotation added to extendWith parameter
boomerangPDS/src/main/java/boomerang/weights/PathConditionWeightOne.java Constructors changed to private to support singleton pattern
boomerangPDS/src/main/java/boomerang/weights/MinDistanceWeightOne.java Constructor made private to enforce singleton pattern
boomerangPDS/src/main/java/boomerang/weights/MinDistanceWeightImpl.java toString method updated to remove redundant weight instantiation
boomerangPDS/src/main/java/boomerang/weights/DataFlowPathWeightOne.java Constructor changed to private to enforce singleton
SynchronizedPDS/src/main/java/sync/pds/weights/SetDomainZero.java Constructor made private in line with singleton usage
SynchronizedPDS/src/main/java/sync/pds/weights/SetDomainOne.java Constructor made private to enforce the singleton design

Copy link
Member

@swissiety swissiety left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@swissiety swissiety merged commit 342fd05 into develop May 6, 2025
4 checks passed
@swissiety swissiety deleted the fix/make-one-zero-weights-singletons branch May 6, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assumptions about static instances in TransitionFunction lead to brittle behavior

3 participants