1717
1818package com .vaticle .typedb .console .command ;
1919
20- import com .vaticle .typedb .client .api .TypeDBClient ;
21- import com .vaticle .typedb .client .api .TypeDBOptions ;
22- import com .vaticle .typedb .client .api .TypeDBSession ;
23- import com .vaticle .typedb .client .api .TypeDBTransaction ;
20+ import com .vaticle .typedb .driver .api .TypeDBDriver ;
21+ import com .vaticle .typedb .driver .api .TypeDBOptions ;
22+ import com .vaticle .typedb .driver .api .TypeDBSession ;
23+ import com .vaticle .typedb .driver .api .TypeDBTransaction ;
2424import com .vaticle .typedb .common .collection .Pair ;
2525import com .vaticle .typedb .console .common .Printer ;
2626import com .vaticle .typedb .console .common .Utils ;
@@ -532,17 +532,17 @@ class Options {
532532
533533 public static String token = "transaction-options" ;
534534
535- static TypeDBOptions from (String [] optionTokens , boolean isCluster ) {
536- if (isCluster ) return parseClusterOptions (optionTokens , new TypeDBOptions ());
535+ static TypeDBOptions from (String [] optionTokens , boolean isEnterprise ) {
536+ if (isEnterprise ) return parseEnterpriseOptions (optionTokens , new TypeDBOptions ());
537537 else return parseCoreOptions (optionTokens , new TypeDBOptions ());
538538 }
539539
540- private static TypeDBOptions parseClusterOptions (String [] optionTokens , TypeDBOptions options ) {
540+ private static TypeDBOptions parseEnterpriseOptions (String [] optionTokens , TypeDBOptions options ) {
541541 for (int i = 0 ; i < optionTokens .length ; i += 2 ) {
542542 String token = optionTokens [i ];
543543 String arg = optionTokens [i + 1 ];
544544 assert token .charAt (0 ) == '-' && token .charAt (1 ) == '-' ;
545- Option <TypeDBOptions > option = Options .Cluster . clusterOption (token .substring (2 ));
545+ Option <TypeDBOptions > option = Options .Enterprise . enterpriseOption (token .substring (2 ));
546546 try {
547547 options = option .build (options , arg );
548548 } catch (IllegalArgumentException e ) {
@@ -606,20 +606,20 @@ static List<Pair<String, String>> helpMenu(List<? extends Option<? extends TypeD
606606 }
607607 }
608608
609- static class Cluster extends Core {
609+ static class Enterprise extends Core {
610610
611- private static List <Option .Cluster > options = withCoreOptions (
612- Option .cluster ("read-any-replica" , Option .Arg .BOOLEAN , "Allow (possibly stale) reads from any replica" , (opt , arg ) -> opt .readAnyReplica ((Boolean ) arg ))
611+ private static List <Option .Enterprise > options = withCoreOptions (
612+ Option .enterprise ("read-any-replica" , Option .Arg .BOOLEAN , "Allow (possibly stale) reads from any replica" , (opt , arg ) -> opt .readAnyReplica ((Boolean ) arg ))
613613 );
614614
615- private static List <Option .Cluster > withCoreOptions (Option .Cluster ... clusterOptions ) {
616- List <Option .Cluster > extendedOptions = new ArrayList <>();
617- Core .options .forEach (opt -> extendedOptions .add (opt .asClusterOption ()));
618- extendedOptions .addAll (Arrays .asList (clusterOptions ));
615+ private static List <Option .Enterprise > withCoreOptions (Option .Enterprise ... enterpriseOptions ) {
616+ List <Option .Enterprise > extendedOptions = new ArrayList <>();
617+ Core .options .forEach (opt -> extendedOptions .add (opt .asEnterpriseOption ()));
618+ extendedOptions .addAll (Arrays .asList (enterpriseOptions ));
619619 return extendedOptions ;
620620 }
621621
622- public static Option <TypeDBOptions > clusterOption (String token ) throws IllegalArgumentException {
622+ public static Option <TypeDBOptions > enterpriseOption (String token ) throws IllegalArgumentException {
623623 return from (token , options );
624624 }
625625
@@ -646,8 +646,8 @@ static Option.Core core(String name, Arg arg, String description, BiFunction<Typ
646646 return new Option .Core (name , arg , description , builder );
647647 }
648648
649- static Option .Cluster cluster (String name , Arg arg , String description , BiFunction <TypeDBOptions , Object , TypeDBOptions > builder ) {
650- return new Option .Cluster (name , arg , description , builder );
649+ static Option .Enterprise enterprise (String name , Arg arg , String description , BiFunction <TypeDBOptions , Object , TypeDBOptions > builder ) {
650+ return new Option .Enterprise (name , arg , description , builder );
651651 }
652652
653653 OPTIONS build (OPTIONS options , String arg ) {
@@ -666,14 +666,14 @@ private Core(String name, Arg arg, String description, BiFunction<TypeDBOptions,
666666 super (name , arg , description , builder );
667667 }
668668
669- Option .Cluster asClusterOption () {
670- return new Option .Cluster (name , arg , description , (clusterOption , arg ) -> builder .apply (clusterOption , arg ));
669+ Option .Enterprise asEnterpriseOption () {
670+ return new Option .Enterprise (name , arg , description , (enterpriseOption , arg ) -> builder .apply (enterpriseOption , arg ));
671671 }
672672 }
673673
674- static class Cluster extends Option <TypeDBOptions > {
674+ static class Enterprise extends Option <TypeDBOptions > {
675675
676- private Cluster (String name , Arg arg , String description , BiFunction <TypeDBOptions , Object , TypeDBOptions > builder ) {
676+ private Enterprise (String name , Arg arg , String description , BiFunction <TypeDBOptions , Object , TypeDBOptions > builder ) {
677677 super (name , arg , description , builder );
678678 }
679679 }
@@ -700,9 +700,9 @@ Object parse(String arg) throws IllegalArgumentException {
700700 }
701701 }
702702
703- static String createHelpMenu (TypeDBClient client , boolean isCluster ) {
703+ static String createHelpMenu (TypeDBDriver driver , boolean isEnterprise ) {
704704 List <Pair <String , String >> menu = new ArrayList <>();
705- if (client .users () != null ) {
705+ if (driver .users () != null ) {
706706 menu .addAll (Arrays .asList (
707707 pair (User .List .helpCommand , User .List .description ),
708708 pair (User .Create .helpCommand , User .Create .description ),
@@ -717,12 +717,12 @@ static String createHelpMenu(TypeDBClient client, boolean isCluster) {
717717 pair (Database .Delete .helpCommand , Database .Delete .description ),
718718 pair (Database .Schema .helpCommand , Database .Schema .description )));
719719
720- if (isCluster ) {
720+ if (isEnterprise ) {
721721 menu .add (pair (Database .Replicas .helpCommand , Database .Replicas .description ));
722722 }
723723
724724 menu .add (pair (Transaction .helpCommand , Transaction .description ));
725- if (isCluster ) menu .addAll (Options .Cluster .helpMenu ());
725+ if (isEnterprise ) menu .addAll (Options .Enterprise .helpMenu ());
726726 else menu .addAll (Options .Core .helpMenu ());
727727
728728 menu .addAll (Arrays .asList (
@@ -733,11 +733,11 @@ static String createHelpMenu(TypeDBClient client, boolean isCluster) {
733733 return Utils .createHelpMenu (menu );
734734 }
735735
736- static REPLCommand readREPLCommand (LineReader reader , Printer printer , String prompt , boolean isCluster ) throws InterruptedException {
736+ static REPLCommand readREPLCommand (LineReader reader , Printer printer , String prompt , boolean isEnterprise ) throws InterruptedException {
737737 REPLCommand command = null ;
738738 while (command == null ) {
739739 String line = Utils .readNonEmptyLine (reader , prompt );
740- command = readREPLCommand (line , reader , isCluster );
740+ command = readREPLCommand (line , reader , isEnterprise );
741741 if (command == null ) {
742742 printer .error ("Unrecognised command, please check help menu" );
743743 }
@@ -746,7 +746,7 @@ static REPLCommand readREPLCommand(LineReader reader, Printer printer, String pr
746746 return command ;
747747 }
748748
749- static REPLCommand readREPLCommand (String line , @ Nullable LineReader passwordReader , boolean isCluster ) {
749+ static REPLCommand readREPLCommand (String line , @ Nullable LineReader passwordReader , boolean isEnterprise ) {
750750 REPLCommand command = null ;
751751 String [] tokens = Utils .splitLineByWhitespace (line );
752752 if (tokens .length == 1 && tokens [0 ].equals (Exit .token )) {
@@ -795,7 +795,7 @@ static REPLCommand readREPLCommand(String line, @Nullable LineReader passwordRea
795795 TypeDBSession .Type sessionType = tokens [2 ].equals ("schema" ) ? TypeDBSession .Type .SCHEMA : TypeDBSession .Type .DATA ;
796796 TypeDBTransaction .Type transactionType = tokens [3 ].equals ("read" ) ? TypeDBTransaction .Type .READ : TypeDBTransaction .Type .WRITE ;
797797 TypeDBOptions options ;
798- if (tokens .length > 4 ) options = Options .from (Arrays .copyOfRange (tokens , 4 , tokens .length ), isCluster );
798+ if (tokens .length > 4 ) options = Options .from (Arrays .copyOfRange (tokens , 4 , tokens .length ), isEnterprise );
799799 else options = new TypeDBOptions ();
800800 command = new Transaction (database , sessionType , transactionType , options );
801801 }
0 commit comments