Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8f3e3c9
feat: Create parent aggregator POM for API/SDK separation
aepfli Aug 26, 2025
bbdfb0d
feat: Create OpenFeature API module with ServiceLoader pattern
aepfli Aug 26, 2025
cfc602d
feat: Create OpenFeature SDK module with ServiceLoader provider
aepfli Aug 26, 2025
22882dc
feat: Complete OpenFeature API module with interface segregation and …
aepfli Aug 26, 2025
da7fbb3
feat: Complete OpenFeature SDK module with full implementation
aepfli Aug 26, 2025
32f59af
refactor: Move internal utilities from API to SDK module
aepfli Aug 26, 2025
21dbef0
fix: Resolve critical Javadoc generation errors and build configuration
aepfli Aug 26, 2025
c16651d
Refactor OpenFeature Java SDK to separate API from implementation
aepfli Aug 26, 2025
65e67ed
feat: Remove Lombok dependency from API module
aepfli Aug 27, 2025
4fb276d
feat: Remove Lombok dependency from SDK module
aepfli Aug 27, 2025
aeccd96
feat: Complete cleanup of legacy files and remove Lombok from SDK tests
aepfli Aug 27, 2025
ebc13b3
feat: Update documentation for multi-module architecture and improve …
aepfli Aug 27, 2025
d4b7dbe
feat: Refactor event details to use composition and comply with OpenF…
aepfli Aug 27, 2025
473a981
feat: Clean up builder patterns and remove unnecessary convenience me…
aepfli Aug 27, 2025
62e080d
refactor: Standardize builders and make POJOs immutable
aepfli Aug 27, 2025
8749528
fix: Update API tests to use builder pattern instead of private const…
aepfli Aug 27, 2025
2c2feef
fix: Correct error handling in hook evaluation and update artifact IDs
aepfli Aug 28, 2025
026395f
refactor: Remove Mockito dependencies from TelemetryTest
aepfli Aug 28, 2025
cc73673
refactor: Complete POJO immutability cleanup and remove unnecessary e…
aepfli Aug 28, 2025
96efa14
refactor: Improve Value.objectToValue() consistency and remove unnece…
aepfli Aug 28, 2025
76cc75b
feat: Add builder patterns to ImmutableContext and ImmutableStructure…
aepfli Aug 29, 2025
851ee13
feat: Add comprehensive test suites for API module classes
aepfli Aug 29, 2025
5466e1f
fix: Improve test coverage, defensive copying, and code quality
aepfli Aug 29, 2025
269e129
fix: Add cucumber-picocontainer dependency for e2e tests
aepfli Aug 29, 2025
f146499
fix: Add module opens for e2e tests to enable Cucumber step definitions
aepfli Aug 29, 2025
724c8c1
fixup: further improve immutability and add release please
aepfli Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
id: release
with:
token: ${{secrets.RELEASE_PLEASE_ACTION_TOKEN}}
prerelease: ${{ github.ref == 'refs/heads/beta' }}
prerelease-type: "beta"
outputs:
release_created: ${{ fromJSON(steps.release.outputs.paths_released)[0] != null }} # if we have a single release path, do the release

Expand Down
5 changes: 4 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{".":"1.16.0"}
{
"./sdk": "2.0.0-beta",
"./api": "0.0.0-beta"
}
219 changes: 219 additions & 0 deletions API_IMPROVEMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# OpenFeature Java API Improvements

This document outlines improvement opportunities for the OpenFeature Java API based on analysis of the current codebase structure.

## Status

βœ… **Completed**: Builder class names have been standardized to use `Builder` instead of class-specific names (e.g., `ImmutableMetadataBuilder` β†’ `Builder`)

## 1. POJO Structure Consistency

### Current Issues
- **Mixed Mutability Patterns**: `ProviderEvaluation` is mutable with both builder pattern AND public setters, while event details are immutable with builders only
- **Constructor Overloading vs Builders**: Some classes provide multiple constructors alongside builders

### Improvement Prompts
```
Make ProviderEvaluation immutable by:
1. Making all fields final
2. Removing public setters (setValue, setVariant, etc.)
3. Adding private constructor that takes all parameters
4. Ensuring builder is the only way to create instances

Remove constructor overloads from POJOs and standardize on builder pattern only for:
- FlagEvaluationDetails
- ProviderEvaluation
- EventDetails
- ProviderEventDetails
```

## 2. Builder Pattern Standardization

### Current Issues
- **Inconsistent Method Names**: Some builders use `addX()` (ImmutableMetadata), others use `x()`
- **Validation Inconsistency**: Some builders validate in `build()`, others in setter methods

### Improvement Prompts
```
Update ImmutableMetadata.Builder to use consistent naming:
- Change addString() β†’ string()
- Change addInteger() β†’ integer()
- Change addLong() β†’ longValue()
- Change addFloat() β†’ floatValue()
- Change addDouble() β†’ doubleValue()
- Change addBoolean() β†’ boolean()

Move all validation logic to build() methods instead of setter methods for:
- All builder classes that currently validate in setters
- Add comprehensive validation in build() with clear error messages

Ensure all builder methods return 'this' for fluent interface consistency
```

## 3. Structure Handling Unification

### Current Issues
- **Inconsistent Context Constructors**: `ImmutableContext` and `MutableContext` have different constructor patterns
- **Value Conversion Duplication**: `convertValue()` method exists in multiple places

### Improvement Prompts
```
Create unified context creation patterns:
1. Add static factory methods: Context.of(), Context.empty(), Context.withTargeting(key)
2. Standardize constructor patterns between ImmutableContext and MutableContext
3. Add builder() static methods to both context types for consistency

Extract value conversion logic:
1. Create ValueConverter utility class
2. Move convertValue() from Structure interface to utility
3. Update all implementations to use centralized conversion logic

Add convenience methods for common structure operations:
- Structure.empty()
- Structure.of(Map<String, Object>)
- Structure.withAttribute(key, value)
```

## 4. Metadata Handling Improvements

### Current Issues
- **Interface Hierarchy**: `ClientMetadata` has deprecated `getName()` method
- **Builder Inconsistency**: `ImmutableMetadata` builder uses `addType()` methods vs standard patterns

### Improvement Prompts
```
Clean up metadata interfaces:
1. Remove deprecated getName() method from ClientMetadata after checking usage
2. Create clear separation between ClientMetadata and generic Metadata
3. Consider if both interfaces are needed or can be unified

Add metadata factory methods:
- Metadata.empty()
- Metadata.of(String name)
- Metadata.builder() shortcuts for common cases

Improve metadata builder ergonomics:
- Add putAll(Map<String, Object>) method
- Add convenience methods for common metadata patterns
```

## 5. Event Details Architecture Refinement

### Current Issues
- **Complex Composition**: `EventDetails` composes `ProviderEventDetails` but both implement same interface

### Improvement Prompts
```
Evaluate event details architecture:
1. Consider if separate ProviderEventDetails and EventDetails are necessary
2. Document the relationship and usage patterns clearly
3. If keeping both, ensure clear distinction in naming and purpose

Add event details convenience methods:
- EventDetails.forProviderError(String providerName, ErrorCode code, String message)
- EventDetails.forProviderReady(String providerName)
- EventDetails.forConfigurationChange(String providerName, List<String> flagsChanged)

Improve event details validation:
- Ensure providerName is always required per OpenFeature spec
- Add validation in builder.build() methods
- Provide clear error messages for invalid states
```

## 6. API Ergonomics and Developer Experience

### High Priority Improvements
```
Add static import friendly factory methods:
- Value.of(Object) for common value creation
- Context.of(String targetingKey) for simple contexts
- Context.of(String targetingKey, Map<String, Object> attributes)

Add null safety annotations:
- @Nullable for optional parameters and return values
- @NonNull for required parameters
- Import javax.annotation or create custom annotations

Create fluent shortcuts for common patterns:
- EvaluationContext.withTargeting(String key)
- FlagEvaluationDetails.success(String flagKey, T value)
- FlagEvaluationDetails.error(String flagKey, T defaultValue, ErrorCode code, String message)
```

### Medium Priority Improvements
```
Reduce method overloading where builders can be used:
- Evaluate if multiple overloaded constructors are needed
- Prefer builder pattern over method overloads for complex objects

Improve error messages and validation:
- Add descriptive error messages in builder validation
- Include parameter names and expected values in exceptions
- Add @throws documentation for checked exceptions

Consider Optional usage for nullable returns:
- Evaluate using Optional<T> instead of null returns
- Focus on public API methods that commonly return null
- Document null-safety contracts clearly
```

### Low Priority Improvements
```
Package structure optimization:
- Consider if all API classes need to be in single package
- Evaluate creating sub-packages for: contexts, events, metadata, evaluation
- Maintain backward compatibility during any restructuring

Documentation improvements:
- Add usage examples in class-level Javadocs
- Include common patterns and anti-patterns
- Add code examples for complex builder usage

Performance optimizations:
- Reduce object allocation in hot paths (evaluation)
- Consider object pooling for frequently created objects
- Optimize map operations in context merging
```

## 7. Checkstyle Fixes Needed

Based on current checkstyle errors:

```
Fix checkstyle issues in:
1. ProviderEventDetails.java:19 - Add empty line before @deprecated tag
2. FlagEvaluationDetails.java:4 - Remove unused Optional import
3. EventDetails.java - Add Javadoc comments for missing builder methods:
- flagsChanged() method
- message() method
- eventMetadata() method
- errorCode() method
```

## Implementation Guidelines

### Breaking Changes
- Document all breaking changes with migration guides
- Consider deprecation periods for public API changes
- Provide automated migration tools where possible

### Backward Compatibility
- Maintain existing public API surface where possible
- Use @Deprecated annotations with clear migration paths
- Version new features appropriately

### Testing Strategy
- Add comprehensive tests for all builder patterns
- Test null safety and validation thoroughly
- Include integration tests for common usage patterns
- Maintain test coverage above 80% for all changes

## Next Steps

1. **Fix Checkstyle Issues** - Address the 6 current checkstyle violations
2. **Prioritize High-Value Changes** - Start with POJO consistency and builder standardization
3. **Create Migration Guide** - Document any breaking changes for users
4. **Update Documentation** - Refresh examples and usage patterns
5. **Performance Testing** - Ensure changes don't negatively impact performance

This document serves as a roadmap for incrementally improving the API while maintaining stability and backward compatibility.
Loading