22
33import com .featurevisor .types .DatafileContent ;
44import com .featurevisor .types .Feature ;
5+ import com .featurevisor .types .EvaluatedFeature ;
6+ import com .featurevisor .types .EvaluatedFeatures ;
57import com .fasterxml .jackson .databind .ObjectMapper ;
68import java .util .Map ;
79import java .util .HashMap ;
@@ -613,7 +615,7 @@ public <T> T getVariableJSON(String featureKey, String variableKey) {
613615 /**
614616 * Get all evaluations
615617 */
616- public Map < String , Object > getAllEvaluations (Map <String , Object > context , List <String > featureKeys , OverrideOptions options ) {
618+ public EvaluatedFeatures getAllEvaluations (Map <String , Object > context , List <String > featureKeys , OverrideOptions options ) {
617619 if (context == null ) {
618620 context = new HashMap <>();
619621 }
@@ -624,15 +626,15 @@ public Map<String, Object> getAllEvaluations(Map<String, Object> context, List<S
624626 options = new OverrideOptions ();
625627 }
626628
627- Map <String , Object > result = new HashMap <>();
629+ Map <String , EvaluatedFeature > result = new HashMap <>();
628630
629631 List <String > keys = featureKeys .isEmpty () ? this .datafileReader .getFeatureKeys () : featureKeys ;
630632 for (String featureKey : keys ) {
631633 // isEnabled
632634 Evaluation flagEvaluation = evaluateFlag (featureKey , context , options );
633635
634- Map < String , Object > evaluatedFeature = new HashMap <> ();
635- evaluatedFeature .put ( "enabled" , Boolean .TRUE .equals (flagEvaluation .getEnabled ()));
636+ EvaluatedFeature evaluatedFeature = new EvaluatedFeature ();
637+ evaluatedFeature .setEnabled ( Boolean .TRUE .equals (flagEvaluation .getEnabled ()));
636638
637639 OverrideOptions opts = new OverrideOptions ()
638640 .sticky (options .getSticky ())
@@ -644,7 +646,7 @@ public Map<String, Object> getAllEvaluations(Map<String, Object> context, List<S
644646 if (this .datafileReader .hasVariations (featureKey )) {
645647 Object variation = getVariation (featureKey , context , opts );
646648 if (variation != null ) {
647- evaluatedFeature .put ( " variation" , variation );
649+ evaluatedFeature .setVariation ( variation . toString () );
648650 }
649651 }
650652
@@ -657,75 +659,24 @@ public Map<String, Object> getAllEvaluations(Map<String, Object> context, List<S
657659 variables .put (variableKey , getVariable (featureKey , variableKey , context , opts ));
658660 }
659661
660- evaluatedFeature .put ( "variables" , variables );
662+ evaluatedFeature .setVariables ( variables );
661663 }
662664
663665 result .put (featureKey , evaluatedFeature );
664666 }
665667
666- return result ;
668+ return EvaluatedFeatures . of ( result ) ;
667669 }
668670
669- public Map < String , Object > getAllEvaluations (Map <String , Object > context , List <String > featureKeys ) {
671+ public EvaluatedFeatures getAllEvaluations (Map <String , Object > context , List <String > featureKeys ) {
670672 return getAllEvaluations (context , featureKeys , null );
671673 }
672674
673- public Map < String , Object > getAllEvaluations (Map <String , Object > context ) {
675+ public EvaluatedFeatures getAllEvaluations (Map <String , Object > context ) {
674676 return getAllEvaluations (context , null , null );
675677 }
676678
677- public Map <String , Object > getAllEvaluations () {
678- return getAllEvaluations (getContext ());
679- }
680-
681- // Static factory methods for direct function-like access
682- /**
683- * Create a new Featurevisor instance with default options
684- * @return new Instance
685- */
686- public static Instance createInstance () {
687- return new Instance (new InstanceOptions ());
688- }
689-
690- /**
691- * Create a new Featurevisor instance with datafile
692- * @param datafile the datafile content
693- * @return new Instance
694- */
695- public static Instance createInstance (DatafileContent datafile ) {
696- InstanceOptions options = new InstanceOptions ();
697- options .setDatafile (datafile );
698- return new Instance (options );
699- }
700-
701- /**
702- * Create a new Featurevisor instance with datafile string
703- * @param datafileString JSON string of the datafile
704- * @return new Instance
705- */
706- public static Instance createInstance (String datafileString ) {
707- InstanceOptions options = new InstanceOptions ();
708- options .setDatafileString (datafileString );
709- return new Instance (options );
710- }
711-
712- /**
713- * Create a new Featurevisor instance with context
714- * @param context the context map
715- * @return new Instance
716- */
717- public static Instance createInstance (Map <String , Object > context ) {
718- InstanceOptions options = new InstanceOptions ();
719- options .setContext (context );
720- return new Instance (options );
721- }
722-
723- /**
724- * Create a new Featurevisor instance with full options
725- * @param options the instance options
726- * @return new Instance
727- */
728- public static Instance createInstance (InstanceOptions options ) {
729- return new Instance (options );
679+ public EvaluatedFeatures getAllEvaluations () {
680+ return getAllEvaluations (null , null , null );
730681 }
731682}
0 commit comments