Fixed formatting issues

Signed-off-by: japaar17 <jain.apaar17@gmail.com>
This commit is contained in:
japaar17 2026-02-08 20:29:56 +05:30
parent a80ab1b3ba
commit 122ad40cb7
3 changed files with 9 additions and 11 deletions

View file

@ -34,8 +34,9 @@ public class FeatureFlagController {
@PutMapping("/{id}")
public ResponseEntity<FeatureFlag> updateFeatureFlag(@PathVariable Long id, @RequestBody FeatureFlag flag) {
return service.updateFeatureFlag(id, flag).map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
return service.updateFeatureFlag(id, flag)
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
}
@DeleteMapping("/{id}")

View file

@ -1,6 +1,7 @@
package org.springframework.samples.petclinic.featureflag.helper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.featureflag.constants.FeatureFlagConstants;
import org.springframework.samples.petclinic.featureflag.service.FeatureEvaluationService;
import org.springframework.stereotype.Component;
@ -16,7 +17,7 @@ public class FeatureFlagHelper {
}
private String getCurrentUser() {
return "anonymous";
return FeatureFlagConstants.ANONYMOUS_USER;
}
}

View file

@ -6,9 +6,8 @@ import org.springframework.samples.petclinic.featureflag.repository.FeatureFlagR
import org.springframework.stereotype.Service;
/**
* Service responsible for evaluating feature flags.
* Supports global enable/disable, whitelist, blacklist,
* and percentage rollout strategies.
* Service responsible for evaluating feature flags. Supports global enable/disable,
* whitelist, blacklist, and percentage rollout strategies.
*/
@Service
public class FeatureEvaluationService {
@ -19,11 +18,8 @@ public class FeatureEvaluationService {
/**
* Determines whether a feature is enabled for a given user.
*
* Evaluation order:
* 1. Global disable check
* 2. Blacklist override
* 3. Whitelist override
* 4. Percentage rollout
* Evaluation order: 1. Global disable check 2. Blacklist override 3. Whitelist
* override 4. Percentage rollout
*/
public boolean isFlagEnabledForUser(String flagName, String userId) {
FeatureFlag flag = featureFlagRepository.findByFlagName(flagName).orElse(null);