f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/java/io/protobase/f7/formulas/info/TYPE.java
-rw-r--r--
1112
 1package io.protobase.f7.formulas.info;
 2
 3import io.protobase.f7.errors.F7Exception;
 4import io.protobase.f7.formulas.AbstractFormula;
 5import io.protobase.f7.formulas.FormulaName;
 6import io.protobase.f7.models.GridColumnRowKey;
 7
 8import java.util.List;
 9import java.util.function.BiFunction;
10import java.util.function.Function;
11
12public class TYPE extends AbstractFormula {
13  public static FormulaName NAME = FormulaName.TYPE;
14  public static TYPE SELF = new TYPE();
15
16  public TYPE() {
17    super();
18  }
19
20  public TYPE(Function<Object, Object> lookup, BiFunction<GridColumnRowKey, Object, Object> collateralLookup) {
21    super(lookup, collateralLookup);
22  }
23
24  @Override
25  public Object internal(GridColumnRowKey origin, Object... args) {
26    checkLength(args.length, 1, NAME);
27    Object first = args[0];
28    if (first instanceof Double) {
29      return 1;
30    }
31    if (first instanceof String) {
32      return 2;
33    }
34    if (first instanceof Boolean) {
35      return 4;
36    }
37    if (first instanceof F7Exception) {
38      return 16;
39    }
40    if (first instanceof List) {
41      return 64;
42    }
43    return 128;
44  }
45}