BuilderExpression class

Пакет: com.hypixel.hytale.server.npc.asset.builder.expression

Файл: com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpression.java

Поля (15)

МодификаторыТипИмя
public static final BuilderExpression.SchemaGenerator INSTANCE
final String STATIC
JsonPrimitive var1
JsonArray var1
BuilderExpression var2
JsonElement var2
Schema var2
BuilderExpression var3
BuilderExpression var3
BuilderExpression var3
BuilderExpression var3
var3
var3
var3
JsonPrimitive var4

Методы (29)

МодификаторыВозвратСигнатура
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Only constant string, number or boolean or arrays allowed, found: " + var0)
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Illegal JSON value for expression: " + var0)
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading number is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading string is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading boolean is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading number array is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading integer is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading string array is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("BuilderExpression: Reading boolean array is not supported")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("This type of builder expression cannot be added to a scope")
abstract throw new IllegalStateExceptionthrow new IllegalStateException("This type of builder expression cannot update a scope")
private SchemaGeneratorprivate SchemaGenerator()
public void addToScopevoid addToScope(String var1, StdScope var2)
public void compilevoid compile(BuilderParameters var1)
public boolean getBooleanboolean getBoolean(ExecutionContext var1)
public boolean[] getBooleanArrayboolean[] getBooleanArray(ExecutionContext var1)
public String getExpressionString getExpression()
public int[] getIntegerArrayint[] getIntegerArray(ExecutionContext var1)
public double getNumberdouble getNumber(ExecutionContext var1)
public double[] getNumberArraydouble[] getNumberArray(ExecutionContext var1)
public String getSchemaNamepublic String getSchemaName()
public String getStringString getString(ExecutionContext var1)
abstract abstract ValueType getTypeValueType getType()
if if(var2 != null)
if if(var3 != null)
abstract abstract boolean isStaticboolean isStatic()
return switchreturn switch(var0.type)
public Schema toSchemapublic Schema toSchema(@Nonnull SchemaContext var1)
public void updateScopevoid updateScope(StdScope var1, String var2, ExecutionContext var3)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.asset.builder.expression;

class="kw">import com.google.gson.JsonArray;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.google.gson.JsonPrimitive;
class="kw">import com.hypixel.hytale.codec.schema.NamedSchema;
class="kw">import com.hypixel.hytale.codec.schema.SchemaContext;
class="kw">import com.hypixel.hytale.codec.schema.SchemaConvertable;
class="kw">import com.hypixel.hytale.codec.schema.config.ArraySchema;
class="kw">import com.hypixel.hytale.codec.schema.config.BooleanSchema;
class="kw">import com.hypixel.hytale.codec.schema.config.NumberSchema;
class="kw">import com.hypixel.hytale.codec.schema.config.Schema;
class="kw">import com.hypixel.hytale.codec.schema.config.StringSchema;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderParameters;
class="kw">import com.hypixel.hytale.server.npc.util.expression.ExecutionContext;
class="kw">import com.hypixel.hytale.server.npc.util.expression.StdScope;
class="kw">import com.hypixel.hytale.server.npc.util.expression.ValueType;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class="kw">abstract class BuilderExpression {
   class="kw">public class="kw">static class="kw">final String STATIC = "<STATIC>";

   class="kw">public BuilderExpression() {
   }

   class="kw">public class="kw">abstract ValueType getType();

   class="kw">public class="kw">abstract boolean isStatic();

   class="kw">public double getNumber(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading number is not supported");
   }

   class="kw">public String getString(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading string is not supported");
   }

   class="kw">public boolean getBoolean(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading boolean is not supported");
   }

   class="kw">public double[] getNumberArray(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading number array is not supported");
   }

   class="kw">public int[] getIntegerArray(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading integer is not supported");
   }

   @Nullable
   class="kw">public String[] getStringArray(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading string array is not supported");
   }

   class="kw">public boolean[] getBooleanArray(ExecutionContext var1) {
      throw new IllegalStateException("BuilderExpression: Reading boolean array is not supported");
   }

   class="kw">public void addToScope(String var1, StdScope var2) {
      throw new IllegalStateException("This type of builder expression cannot be added to a scope");
   }

   class="kw">public void updateScope(StdScope var1, String var2, ExecutionContext var3) {
      throw new IllegalStateException("This type of builder expression cannot update a scope");
   }

   class="kw">public String getExpression() {
      class="kw">return "<STATIC>";
   }

   @Nonnull
   class="kw">public class="kw">static BuilderExpression fromOperand(@Nonnull ExecutionContext.Operand var0) {
      class="kw">return class="kw">switch (var0.type) {
         case NUMBER -> new BuilderExpressionStaticNumber(var0.number);
         case STRING -> new BuilderExpressionStaticString(var0.string);
         case BOOLEAN -> new BuilderExpressionStaticBoolean(var0.bool);
         case EMPTY_ARRAY -> BuilderExpressionStaticEmptyArray.INSTANCE;
         case NUMBER_ARRAY -> new BuilderExpressionStaticNumberArray(var0.numberArray);
         case STRING_ARRAY -> new BuilderExpressionStaticStringArray(var0.stringArray);
         case BOOLEAN_ARRAY -> new BuilderExpressionStaticBooleanArray(var0.boolArray);
         class="kw">default -> throw new IllegalStateException("Operand cannot be converted to builder expression");
      };
   }

   @Nonnull
   class="kw">public class="kw">static BuilderExpression fromJSON(@Nonnull JsonElement var0, @Nonnull BuilderParameters var1, boolean var2) {
      BuilderExpression var3 = fromJSON(var0, var1);
      if (var2 && !var3.isStatic()) {
         throw new IllegalArgumentException("Only constant string, number or boolean or arrays allowed, found: " + var0);
      } else {
         class="kw">return var3;
      }
   }

   @Nonnull
   class="kw">public class="kw">static BuilderExpression fromJSON(@Nonnull JsonElement var0, @Nonnull BuilderParameters var1, ValueType var2) {
      BuilderExpression var3 = fromJSON(var0, var1);
      if (!ValueType.isAssignableType(var3.getType(), var2)) {
         throw new IllegalStateException("Expression type mismatch. Got " + var3.getType() + " but expected " + var2 + " from: " + var0);
      } else {
         class="kw">return var3;
      }
   }

   @Nonnull
   class="kw">public class="kw">static BuilderExpression fromJSON(@Nonnull JsonElement var0, @Nonnull BuilderParameters var1) {
      if (var0.isJsonObject()) {
         class="kw">return BuilderExpressionDynamic.fromJSON(var0, var1);
      }

      if (var0.isJsonPrimitive()) {
         BuilderExpression var2 = readJSONPrimitive(var0);
         if (var2 != null) {
            class="kw">return var2;
         }
      } else if (var0.isJsonArray()) {
         BuilderExpression var3 = readStaticArray(var0);
         if (var3 != null) {
            class="kw">return var3;
         }
      }

      throw new IllegalArgumentException("Illegal JSON value for expression: " + var0);
   }

   @Nullable
   class="kw">private class="kw">static BuilderExpression readJSONPrimitive(@Nonnull JsonElement var0) {
      JsonPrimitive var1 = var0.getAsJsonPrimitive();
      if (var1.isString()) {
         class="kw">return new BuilderExpressionStaticString(var1.getAsString());
      } else if (var1.isBoolean()) {
         class="kw">return new BuilderExpressionStaticBoolean(var1.getAsBoolean());
      } else {
         class="kw">return var1.isNumber() ? new BuilderExpressionStaticNumber(var1.getAsDouble()) : null;
      }
   }

   @Nullable
   class="kw">private class="kw">static BuilderExpression readStaticArray(@Nonnull JsonElement var0) {
      JsonArray var1 = var0.getAsJsonArray();
      if (var1.isEmpty()) {
         class="kw">return BuilderExpressionStaticEmptyArray.INSTANCE;
      }

      JsonElement var2 = var1.get(0);
      BuilderExpression var3 = null;
      if (var2.isJsonPrimitive()) {
         JsonPrimitive var4 = var2.getAsJsonPrimitive();
         if (var4.isString()) {
            var3 = BuilderExpressionStaticStringArray.fromJSON(var1);
         } else if (var4.isBoolean()) {
            var3 = BuilderExpressionStaticBooleanArray.fromJSON(var1);
         } else if (var4.isNumber()) {
            var3 = BuilderExpressionStaticNumberArray.fromJSON(var1);
         }
      }

      class="kw">return var3;
   }

   class="kw">public void compile(BuilderParameters var1) {
   }

   @Nonnull
   class="kw">public class="kw">static Schema toSchema(@Nonnull SchemaContext var0) {
      class="kw">return var0.refDefinition(BuilderExpression.SchemaGenerator.INSTANCE);
   }

   class="kw">private class="kw">static class SchemaGenerator class="kw">implements SchemaConvertable<Void>, NamedSchema {
      @Nonnull
      class="kw">public class="kw">static class="kw">final BuilderExpression.SchemaGenerator INSTANCE = new BuilderExpression.SchemaGenerator();

      class="kw">private SchemaGenerator() {
      }

      @Nonnull
      @Override
      class="kw">public String getSchemaName() {
         class="kw">return "NPC:Type:BuilderExpression";
      }

      @Nonnull
      @Override
      class="kw">public Schema toSchema(@Nonnull SchemaContext var1) {
         Schema var2 = new Schema();
         var2.setTitle("Expression");
         var2.setAnyOf(new ArraySchema(), new NumberSchema(), new StringSchema(), new BooleanSchema(), BuilderExpressionDynamic.toSchema());
         class="kw">return var2;
      }
   }
}