1414import java .io .Serializable ;
1515import java .util .EnumMap ;
1616import java .util .Map ;
17+ import java .util .Objects ;
1718import java .util .function .Function ;
1819
1920/**
@@ -36,6 +37,7 @@ public interface UnaryOperator extends Serializable {
3637 UNARY_OPERATORS .put (Operation .ABS , UnaryOperations ::abs );
3738 UNARY_OPERATORS .put (Operation .LOWER , UnaryOperations ::lower );
3839 UNARY_OPERATORS .put (Operation .UPPER , UnaryOperations ::upper );
40+ UNARY_OPERATORS .put (Operation .HASH , UnaryOperations ::hash );
3941 }
4042
4143 static TypedObject not (Evaluator evaluator , BulletRecord record ) {
@@ -61,20 +63,6 @@ static TypedObject trim(Evaluator evaluator, BulletRecord record) {
6163 });
6264 }
6365
64- static TypedObject lower (Evaluator evaluator , BulletRecord record ) {
65- return checkNull (evaluator , record , value -> {
66- String str = (String ) value .getValue ();
67- return TypedObject .valueOf (str .toLowerCase ());
68- });
69- }
70-
71- static TypedObject upper (Evaluator evaluator , BulletRecord record ) {
72- return checkNull (evaluator , record , value -> {
73- String str = (String ) value .getValue ();
74- return TypedObject .valueOf (str .toUpperCase ());
75- });
76- }
77-
7866 static TypedObject abs (Evaluator evaluator , BulletRecord record ) {
7967 return checkNull (evaluator , record , value -> {
8068 Number number = (Number ) value .getValue ();
@@ -91,6 +79,24 @@ static TypedObject abs(Evaluator evaluator, BulletRecord record) {
9179 });
9280 }
9381
82+ static TypedObject lower (Evaluator evaluator , BulletRecord record ) {
83+ return checkNull (evaluator , record , value -> {
84+ String str = (String ) value .getValue ();
85+ return TypedObject .valueOf (str .toLowerCase ());
86+ });
87+ }
88+
89+ static TypedObject upper (Evaluator evaluator , BulletRecord record ) {
90+ return checkNull (evaluator , record , value -> {
91+ String str = (String ) value .getValue ();
92+ return TypedObject .valueOf (str .toUpperCase ());
93+ });
94+ }
95+
96+ static TypedObject hash (Evaluator evaluator , BulletRecord record ) {
97+ return TypedObject .valueOf (Objects .hashCode (evaluator .evaluate (record ).getValue ()));
98+ }
99+
94100 private static TypedObject checkNull (Evaluator evaluator , BulletRecord record , Function <TypedObject , TypedObject > operator ) {
95101 TypedObject value = evaluator .evaluate (record );
96102 if (Utilities .isNull (value )) {
0 commit comments