Skip to content

MetaObjects v6.2.6 - Revolutionary Fluent Constraint System

Choose a tag to compare

@dmealing dmealing released this 04 Oct 15:20

🚀 MetaObjects v6.2.6 - Revolutionary Fluent Constraint System

This release represents a major evolutionary step for the MetaObjects framework, introducing a sophisticated fluent constraint system that provides elegant APIs, comprehensive validation, and universal array support while maintaining all architectural principles.

🌟 Major Features

🔧 Fluent AttributeConstraintBuilder API

  • Chainable Methods: Elegant constraint building with ofType(), withEnum(), asSingle(), asArray(), withConstraints()
  • Type-Safe Definitions: Compile-time checking of constraint definitions with enhanced error reporting
  • Clean Syntax: Readable and maintainable constraint definitions
    Example Usage:
    java
    // Single-value string attribute with enumeration
    def.optionalAttributeWithConstraints(ATTR_GENERATION)
    .ofType(StringAttribute.SUBTYPE_STRING)
    .asSingle()
    .withEnum(GENERATION_INCREMENT, GENERATION_UUID, GENERATION_ASSIGNED);

// Array-value string attribute
def.optionalAttributeWithConstraints(ATTR_FIELDS)
.ofType(StringAttribute.SUBTYPE_STRING)
.asArray();

plaintext

🎲 Universal @isarray Implementation

  • Type Explosion Elimination: Universal @isarray modifier replaces dedicated array subtypes
  • Reduced Complexity: 6 core field types instead of 12+ with unlimited array combinations
  • Cross-Platform Ready: Array types map cleanly to Java, C#, TypeScript

📊 Comprehensive Constraint Coverage

  • 115+ Constraints: Comprehensive validation coverage across all 19 modules
  • 57 Placement Constraints: Define "X can contain Y" relationships
  • 28 Validation Constraints: Define "X must have valid Y" rules
  • 30 Array-Specific Constraints: Universal @isarray support

🔧 Enhanced ConstraintEnforcer Architecture

  • Attribute-Specific Validation: Precise attribute-level constraint checking
  • Comprehensive Pipeline: Traditional placement + new attribute + enhanced validation constraints
  • Context Preservation: Detailed error reporting with metadata context

🏗️ Architecture Improvements

Files Updated (43 files changed)

  • Field Classes: StringField, IntegerField, LongField, DoubleField, FloatField, DecimalField, DateField, TimeField, TimestampField, ObjectField, MetaField
  • Attribute Classes: MetaAttribute
  • Validator Classes: MetaValidator, RegexValidator, LengthValidator, ArrayValidator
  • View Classes: MetaView
  • Relationship Classes: MetaRelationship

Pattern Conversion Applied

Before:
java
.optionalAttribute(ATTR_NAME, TYPE)
plaintext
After:
java
def.optionalAttributeWithConstraints(ATTR_NAME)
.ofType(TYPE)
.asSingle();
plaintext

🧪 Quality Assurance

  • Build Success: All 19 modules compiling and packaging successfully
  • Test Coverage: 250/250 tests passing across entire framework
  • Architecture Compliance: Read-optimized patterns, OSGI compatibility, WeakHashMap preservation
  • Provider Integration: Seamless integration with provider-based registration system

📁 Key Implementation Files

Core Fluent Constraint System:

  • metadata/src/main/java/com/metaobjects/registry/AttributeConstraintBuilder.java - Fluent API implementation
  • metadata/src/main/java/com/metaobjects/constraint/ConstraintEnforcer.java - Enhanced enforcement engine
    Integration Points:
  • metadata/src/main/java/com/metaobjects/registry/TypeDefinitionBuilder.java - Fluent integration
  • All field, attribute, validator, view, and relationship classes updated

🔮 Future Enhancement Capabilities

The fluent constraint system provides a robust foundation for:

  • Custom business rules with fluent API
  • Cross-reference validation between metadata elements
  • Dynamic constraint loading capabilities
  • Multi-language constraint support
  • Constraint versioning and migration

🤖 Generated with Claude Code
Full Changelog: v6.2.5...v6.2.6